一、环境描述
Oracle 12c 单实例DataGuard
Rhel 7.3
二、测试过程
主库操作
1.关闭DG,切换日志
SQL> alter system set log_archive_dest_state_2=defer;
System altered.
SQL> show parameter log_archive_dest_state_2
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_state_2 string DEFER
log_archive_dest_state_20 string enable
log_archive_dest_state_21 string enable
log_archive_dest_state_22 string enable
log_archive_dest_state_23 string enable
log_archive_dest_state_24 string enable
log_archive_dest_state_25 string enable
log_archive_dest_state_26 string enable
log_archive_dest_state_27 string enable
log_archive_dest_state_28 string enable
log_archive_dest_state_29 string enable
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL>
2.rman删除归档
RMAN> list archivelog all;
List of Archived Log Copies for database with db_unique_name ORCL
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - --------------------
40 1 31 A 26-NOV-2017 19:15:13
Name: /oracle/arch/1_31_958415134.dbf
42 1 32 A 26-NOV-2017 19:22:34
Name: /oracle/arch/1_32_958415134.dbf
RMAN> delete noprompt archivelog all;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=39 device type=DISK
RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
archived log file name=/oracle/arch/1_32_958415134.dbf thread=1 sequence=32
List of Archived Log Copies for database with db_unique_name ORCL
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - --------------------
40 1 31 A 26-NOV-2017 19:15:13
Name: /oracle/arch/1_31_958415134.dbf
deleted archived log
archived log file name=/oracle/arch/1_31_958415134.dbf RECID=40 STAMP=961096954
Deleted 1 objects
RMAN>
三、小结
当我们DG环境,人为或者异常情况导致DG异常,没有被应用的归档日志是不会被删除的。这里可能会出现一个问题就是
当我们的磁盘空间紧张,可能生成大量的日志占满磁盘,导致数据库无法写入的问题。需要我们有监控系统,发现DG异常及时处理
,千万不要等着影响业务才被动的去处理。