因为Oracle archivelog会不断生产,一般会设置定期清理archivelog的排程,类似下面。
但DG环境中因为某些原因导致主库事务没有即使传到standby,而这时如果主库的archivelog也被清理掉了,主备库就产生了日志GAP
export ORACLE_SID=abc
export ORACLE_HOME=/u01/product/oracle/
export PATH=
O
R
A
C
L
E
H
O
M
E
/
b
i
n
:
ORACLE_HOME/bin:
ORACLEHOME/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
- 主库rman中配置
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;
- 主库切换生成新log,模拟gap
SQL> 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’ ;
完整实例:http://github.crmeb.net/u/defu
来自 “开源世界 ” ,链接:http://ym.baisou.ltd/post/610.html,如需转载,请注明出处,否则将追究法律责任