通过RMAN设置standby接收日志后主库归档日志才可删除

来源:这里教程网 时间:2026-03-03 15:37:41 作者:

因为Oracle archivelog会不断生产,一般会设置定期清理archivelog的排程,类似下面。但DG环境中因为某些原因导致主库事务没有即使传到standby,而这时如果主库的archivelog也被清理掉了,主备库就产生了日志GAP export  ORACLE_SID=abc export  ORACLE_HOME=/u01/product/oracle/ export  PATH=$ORACLE_HOME/bin:$PATH export NLS_LANG=AMERICAN_AMERICA.AL32UTF8 rman target / <<EOF run  { crosscheck archivelog all; DELETE NOPROMPT ARCHIVELOG until time 'sysdate-7'; } exit; EOF 如何能够确保standby日志接收到了,主库archivelog才会被删除呢?11G 后提供了RMAN的archivelog删除策略 CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY; 注:这里是说archivelog在standby目录中接收生产了,并不是被实际应用了。 因为这样说?一种情况standby正常开启,但MPR不开启应用redo,其实standby也能接收主库传递过来的archivelog但并没有被应用,这时主库的archivelog是可以被清理的 默认 CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON NONE;SHOW ALL 命令能看到 实验1.关闭standby DB,模拟standby无法接受archivelog 2. 主库rman中配置CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY; 3. 主库切换生成新log,模拟gapSQL> alter system switch logfile;SQL> / 4.因为standby未接收到archivelog,对主库备份archivelog同时加了DELETE INPUT清理归档报错RMAM-08120

RMAN> backup format '/data/exp/arch_%T_%s_%U' ARCHIVELOG ALL DELETE INPUT;
Starting backup at 13-MAY-20 current log archived using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=9 device type=DISK channel ORA_DISK_1: starting archived log backup set channel ORA_DISK_1: specifying archived log(s) in backup set input archived log thread=1 sequence=12585 RECID=25142 STAMP=1040319318 input archived log thread=1 sequence=12586 RECID=25144 STAMP=1040319532 input archived log thread=1 sequence=12587 RECID=25146 STAMP=1040319628 input archived log thread=1 sequence=12588 RECID=25147 STAMP=1040320146 channel ORA_DISK_1: starting piece 1 at 13-MAY-20 channel ORA_DISK_1: finished piece 1 at 13-MAY-20 piece handle=/data/exp/arch_20200513_10_0av041ki_1_1 tag=TAG20200513T174906 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 channel ORA_DISK_1: deleting archived log(s) archived log file name=/data/epodb/arch/1_12585_893259821.arc RECID=25142 STAMP=1040319318 archived log file name=/data/epodb/arch/1_12586_893259821.arc RECID=25144 STAMP=1040319532 RMAN-08120: WARNING: archived log not deleted, not yet applied by standby archived log file name=/data/epodb/arch/1_12587_893259821.arc thread=1 sequence=12587 RMAN-08120: WARNING: archived log not deleted, not yet applied by standby archived log file name=/data/epodb/arch/1_12588_893259821.arc thread=1 sequence=12588 Finished backup at 13-MAY-20

5.因为standby未接收到archivelog,对主库delete archivelog报错RMAM-08120

RMAN> delete archivelog until time 'sysdate' ;
released channel: ORA_DISK_1 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=9 device type=DISK RMAN-08120: WARNING: archived log not deleted, not yet applied by standby archived log file name=/data/epodb/arch/1_12587_893259821.arc thread=1 sequence=12587 RMAN-08120: WARNING: archived log not deleted, not yet applied by standby archived log file name=/data/epodb/arch/1_12588_893259821.arc thread=1 sequence=12588

注:如果带上FORCE参数可以忽略 RMAM-08120直接删除archivelog, delete FORCE archivelog until time 'sysdate' ;

相关推荐