DG环境下delete obsolete对于archivelog deletion policy的影响
Note: DELETE OBSOLETE considers only the backup retention policy and does not use the configured archived log deletion policy to determine which logs are obsolete. In contrast, DELETE ARCHIVELOG ALL considers only the configured archived log deletion policy.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
上面的文章出自http://docs.oracle.com/cd/E11882_01/backup.112/e10643/rcmsynta016.htm#RCMRF121中obsolete参数解释,我做了几个实验。验证了在DATAGUARD
下,rman参数设置CONFIGURE ARCHIVELOG DELETION POLICY TO存在bug。下面是我的实验,两台单机11.2.0.4搭建的dg环境。
数据库版本11.2.0.4 DATA GUARD(主备都是单机)
实验一
我在主库rman里配置的归档删除策略参数是:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;
备库的参数是none,
我做如下测试
1)备库置于mount standby database 不开启mrp应用,此时检查进程,没有应用恢复进程
SELECT PROCESS, STATUS,THREAD#,SEQUENCE#,BLOCK#,BLOCKS, DELAY_MINS FROM V$MANAGED_STANDBY;
PROCESS STATUS THREAD# SEQUENCE# BLOCK# BLOCKS DELAY_MINS
--------- ------------ ---------- ---------- ---------- ---------- ----------
ARCH CONNECTED 0 0 0 0 0
ARCH CONNECTED 0 0 0 0 0
ARCH CONNECTED 0 0 0 0 0
ARCH CONNECTED 0 0 0 0 0
在主库中执行日志切换数次
aler system archive log current;
2)执行一次0级备份
backup incremental level 0 format '/rmanbackup/xu_1_%U'database;
我的备份保留策略为1
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
3)再执行一次level 0备份
backup incremental level 0 format '/rmanbackup/xu_2_%U' database;
这样前一次的备份已经过期。
4)在主库查询归档日志的最大序号
SQL> select thread#, max(sequence#) from v$archived_log group by thread#;
THREAD# MAX(SEQUENCE#)
---------- --------------
1 173
在备库应用的归档日志最大序号
SQL> select thread#,max(sequence#) from v$archived_log where applied='YES' group by thread#;
THREAD# MAX(SEQUENCE#)
---------- --------------
1 157
在备库查收到的归档日志最大序号
SQL> select thread#, max(sequence#) from v$archived_log group by thread#;
THREAD# MAX(SEQUENCE#)
---------- --------------
1 174
主库此时也是174
4)在RMAN中执行delete obsolete 命令
RMAN> delete obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Archive Log 311 20-JAN-16 /arch/1_158_901532232.dbf
Archive Log 312 20-JAN-16 /arch/1_159_901532232.dbf
Archive Log 313 20-JAN-16 /arch/1_160_901532232.dbf
Archive Log 314 20-JAN-16 /arch/1_161_901532232.dbf
Archive Log 315 20-JAN-16 /arch/1_162_901532232.dbf
Archive Log 317 20-JAN-16 /arch/1_164_901532232.dbf
Archive Log 316 20-JAN-16 /arch/1_163_901532232.dbf
Archive Log 318 20-JAN-16 /arch/1_165_901532232.dbf
Archive Log 319 20-JAN-16 /arch/1_166_901532232.dbf
Backup Set 67 20-JAN-16
Backup Piece 67 20-JAN-16 /rmanbackup/orcl_full_lei_5_24qrr52a_1_1
Archive Log 320 20-JAN-16 /arch/1_167_901532232.dbf
Archive Log 321 20-JAN-16 /arch/1_168_901532232.dbf
Backup Set 69 20-JAN-16
Backup Piece 69 20-JAN-16 /rmanbackup/orcl_inc_26qrsm16_1_1
Archive Log 322 20-JAN-16 /arch/1_169_901532232.dbf
Archive Log 323 21-JAN-16 /arch/1_170_901532232.dbf
Backup Set 70 20-JAN-16
Backup Piece 70 20-JAN-16 /rmanbackup/orcl_arch_inc_27qrsm1e_1_1
Archive Log 324 21-JAN-16 /arch/1_171_901532232.dbf
Archive Log 325 21-JAN-16 /arch/1_172_901532232.dbf
Archive Log 326 21-JAN-16 /arch/1_173_901532232.dbf
Do you really want to delete the above objects (enter YES or NO)?
显示可以删除(之前实验确实是可以删除的,因为备库未应用,所以不输入yes)
结果是我主库设置的CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;未生效,归档日志可以删除。
-------------------------------------------------------------------------------------------------
实验二
--------------------------------------------------------------------------------------------------
1)备库开启mrp恢复
alter database recover managed standby database using current logfile disconnect from session;
查看备库应用归档日志的最大序号
SQL> select thread#,max(sequence#) from v$archived_log where applied='YES' group by thread#;
THREAD# MAX(SEQUENCE#)
---------- --------------
1 174
2)主库阻塞传输到备库的归档日志
SQL> alter system set log_archive_dest_state_2=defer;
System altered.
主库切几组日志
查看主库最大归档日志序号
SQL> select thread#, max(sequence#) from v$archived_log group by thread#;
THREAD# MAX(SEQUENCE#)
---------- --------------
1 183
查看备库此时接收的最大归档日志号
SQL> select thread#, max(sequence#) from v$archived_log group by thread#;
THREAD# MAX(SEQUENCE#)
---------- --------------
1 176
3)主库rman执行一次0级备份
backup incremental level 0 format '/rmanbackup/xu_3_%U'database;
此时第二次的0级备份失效,应该可以删除
执行delete obsolete
RMAN> delete obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
RMAN-08120: WARNING: archived log not deleted, not yet applied by standby
archived log file name=/arch/1_177_901532232.dbf thread=1 sequence=177
RMAN-08120: WARNING: archived log not deleted, not yet applied by standby
archived log file name=/arch/1_178_901532232.dbf thread=1 sequence=178
RMAN-08120: WARNING: archived log not deleted, not yet applied by standby
archived log file name=/arch/1_179_901532232.dbf thread=1 sequence=179
RMAN-08120: WARNING: archived log not deleted, not yet applied by standby
archived log file name=/arch/1_180_901532232.dbf thread=1 sequence=180
RMAN-08120: WARNING: archived log not deleted, not yet applied by standby
archived log file name=/arch/1_181_901532232.dbf thread=1 sequence=181
RMAN-08120: WARNING: archived log not deleted, not yet applied by standby
archived log file name=/arch/1_182_901532232.dbf thread=1 sequence=182
RMAN-08120: WARNING: archived log not deleted, not yet applied by standby
archived log file name=/arch/1_183_901532232.dbf thread=1 sequence=183
Deleting the following obsolete backups and copies:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Archive Log 311 20-JAN-16 /arch/1_158_901532232.dbf
Archive Log 312 20-JAN-16 /arch/1_159_901532232.dbf
Archive Log 313 20-JAN-16 /arch/1_160_901532232.dbf
Archive Log 314 20-JAN-16 /arch/1_161_901532232.dbf
Archive Log 315 20-JAN-16 /arch/1_162_901532232.dbf
Archive Log 317 20-JAN-16 /arch/1_164_901532232.dbf
Archive Log 316 20-JAN-16 /arch/1_163_901532232.dbf
Archive Log 318 20-JAN-16 /arch/1_165_901532232.dbf
Archive Log 319 20-JAN-16 /arch/1_166_901532232.dbf
Backup Set 67 20-JAN-16
Backup Piece 67 20-JAN-16 /rmanbackup/orcl_full_lei_5_24qrr52a_1_1
Archive Log 320 20-JAN-16 /arch/1_167_901532232.dbf
Archive Log 321 20-JAN-16 /arch/1_168_901532232.dbf
Backup Set 69 20-JAN-16
Backup Piece 69 20-JAN-16 /rmanbackup/orcl_inc_26qrsm16_1_1
Archive Log 322 20-JAN-16 /arch/1_169_901532232.dbf
Archive Log 323 21-JAN-16 /arch/1_170_901532232.dbf
Backup Set 70 20-JAN-16
Backup Piece 70 20-JAN-16 /rmanbackup/orcl_arch_inc_27qrsm1e_1_1
Archive Log 324 21-JAN-16 /arch/1_171_901532232.dbf
Archive Log 325 21-JAN-16 /arch/1_172_901532232.dbf
Archive Log 326 21-JAN-16 /arch/1_173_901532232.dbf
Backup Set 71 21-JAN-16
Backup Piece 71 21-JAN-16 /rmanbackup/xu_1_28qrt1bn_1_1
Archive Log 327 21-JAN-16 /arch/1_174_901532232.dbf
Backup Set 72 21-JAN-16
Backup Piece 72 21-JAN-16 /rmanbackup/xu_1_29qrt1de_1_1
Archive Log 346 21-JAN-16 /arch/1_175_901532232.dbf
Archive Log 347 21-JAN-16 /arch/1_176_901532232.dbf
Do you really want to delete the above objects (enter YES or NO)?
产生报错
RMAN-08120: WARNING: archived log not deleted, not yet applied by standby
archived log file name=/arch/1_177_901532232.dbf thread=1 sequence=177
意思是未应用的standby?输入yes
Do you really want to delete the above objects (enter YES or NO)? yes
deleted archived log
archived log file name=/arch/1_158_901532232.dbf RECID=311 STAMP=901616491
deleted archived log
archived log file name=/arch/1_159_901532232.dbf RECID=312 STAMP=901616503
deleted archived log
archived log file name=/arch/1_160_901532232.dbf RECID=313 STAMP=901616503
deleted archived log
archived log file name=/arch/1_161_901532232.dbf RECID=314 STAMP=901616513
deleted archived log
archived log file name=/arch/1_162_901532232.dbf RECID=315 STAMP=901616514
deleted archived log
archived log file name=/arch/1_164_901532232.dbf RECID=317 STAMP=901616518
deleted archived log
archived log file name=/arch/1_163_901532232.dbf RECID=316 STAMP=901616518
deleted archived log
archived log file name=/arch/1_165_901532232.dbf RECID=318 STAMP=901616650
deleted archived log
archived log file name=/arch/1_166_901532232.dbf RECID=319 STAMP=901616714
deleted backup piece
backup piece handle=/rmanbackup/orcl_full_lei_5_24qrr52a_1_1 RECID=67 STAMP=901616714
deleted archived log
archived log file name=/arch/1_167_901532232.dbf RECID=320 STAMP=901660547
deleted archived log
archived log file name=/arch/1_168_901532232.dbf RECID=321 STAMP=901666860
deleted backup piece
backup piece handle=/rmanbackup/orcl_inc_26qrsm16_1_1 RECID=69 STAMP=901666857
deleted archived log
archived log file name=/arch/1_169_901532232.dbf RECID=322 STAMP=901666861
deleted archived log
archived log file name=/arch/1_170_901532232.dbf RECID=323 STAMP=901678317
deleted backup piece
backup piece handle=/rmanbackup/orcl_arch_inc_27qrsm1e_1_1 RECID=70 STAMP=901666862
deleted archived log
archived log file name=/arch/1_171_901532232.dbf RECID=324 STAMP=901678319
deleted archived log
archived log file name=/arch/1_172_901532232.dbf RECID=325 STAMP=901678321
deleted archived log
archived log file name=/arch/1_173_901532232.dbf RECID=326 STAMP=901678322
deleted backup piece
backup piece handle=/rmanbackup/xu_1_28qrt1bn_1_1 RECID=71 STAMP=901678455
deleted archived log
archived log file name=/arch/1_174_901532232.dbf RECID=327 STAMP=901679423
deleted backup piece
backup piece handle=/rmanbackup/xu_1_29qrt1de_1_1 RECID=72 STAMP=901678513
deleted archived log
archived log file name=/arch/1_175_901532232.dbf RECID=346 STAMP=901680413
deleted archived log
archived log file name=/arch/1_176_901532232.dbf RECID=347 STAMP=901680692
Deleted 24 objects
观察序号发现176以后的日志未删除,此时看起来好像是生效的。那么参数
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY; 在我阻塞传输可以生效未应用的归档不能删除,未阻塞传输时失效归档可以删除。
现在弄不清楚APPLIED ON STANDBY到底生效不?
-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------
实验三 (此实验是为了验证备库认为的应用完成是否是认为传输过去就是应用完成)
1)修改主库参数
RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO SHIPPED TO STANDBY;
此时主库日志传输仍然是阻塞状态
log_archive_dest_state_2 string DEFER
2)执行一次level 0备份
backup incremental level 0 format '/rmanbackup/xu_4_%U' database;
3)执行delete obsolete
RMAN> delete obsolete
2> ;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Archive Log 349 21-JAN-16 /arch/1_177_901532232.dbf
Archive Log 350 21-JAN-16 /arch/1_178_901532232.dbf
Archive Log 351 21-JAN-16 /arch/1_179_901532232.dbf
Archive Log 352 21-JAN-16 /arch/1_180_901532232.dbf
Archive Log 353 21-JAN-16 /arch/1_181_901532232.dbf
Archive Log 354 21-JAN-16 /arch/1_182_901532232.dbf
Archive Log 355 21-JAN-16 /arch/1_183_901532232.dbf
Backup Set 73 21-JAN-16
Backup Piece 73 21-JAN-16 /rmanbackup/xu_3_2aqrt3r7_1_1
Backup Set 74 21-JAN-16
Backup Piece 74 21-JAN-16 /rmanbackup/xu_3_2bqrt3sv_1_1
Do you really want to delete the above objects (enter YES or NO)?
未报错,可以删除。
综合三个实验,对于delete obsolete命令下删除归档日志的策略到底生效不生效产生疑问。参照文档
http://docs.oracle.com/cd/E11882_01/backup.112/e10643/rcmsynta016.htm#RCMRF121中obsolete参数解释
Note: DELETE OBSOLETE considers only the backup retention policy and does not use the configured archived log deletion
policy to determine which logs are obsolete. In contrast, DELETE ARCHIVELOG ALL considers only the configured archived
log deletion policy.
我需要的是obsolete delete可以删除备份集但归档日志的删除要看备库日志是否应用,应用了才
可以删除主库的归档日志。我到底该如何使用CONFIGURE ARCHIVELOG DELETION POLICY TO参数