本帖最后由 denglj 于 2022-9-20 13:29 编辑
适用场景:主备不同步,主库归档日志已删除且无备份. 解决方案:主库增量备份修复dg备库中的gap. 具体步骤: 1、停止同步> alter database recover managed standby database cancel; 2、最小scn备库查询最小scn号. > select to_char(current_scn) from v$database;
3、备份
在主库进行增量备份. 说明:3162298为第2部查询出来的最小scn. $ rman target /RMAN> backup as compressed backupset incremental from scn 3162298 database format '/home/oracle/fsbak/forstandby_%U' tag 'FORSTANDBY';
RMAN> backup current controlfile for standby format '/home/oracle/fsbak/forstandbyctl.bck';
说明:使用基于scn的增量备份.因为备库的当前scn卡在3162298处,所以主库的增量备份应该是从scn=3162298往后备份,一直备份完所有的数据文件块.这样备库缺少的gap事务就包含在备份集中,增量恢复到备库后缺失的gap对应的事务就被恢复到数据文件中.
4、传输备份集将备份拷贝至备库. scp /home/oracle/fsbak/* oracle@s192.168.133.120:/home/oracle/fsbak/
5、恢复控制文件备库恢复控制文件. RMAN> shutdown immediate;
RMAN> startup nomount;
RMAN> restore standby controlfile from '/home/oracle/fsbak/forstandbyctl.bck';
6、恢复数据文件
备库查看备份集信息,确认控制文件中记录的备份集路径和备库上的备份集的实际路径是否相同。如果不同删除控制文件中记录的备份集信息,重新注册备份集.
RMAN> alter database mount;
RMAN> crosscheck backup;
RMAN> crosscheck archivelog all;
RMAN> delete noprompt obsolete;
RMAN> delete noprompt expired backup;
RMAN> delete noprompt expired archivelog all;
RMAN> delete backup;
RMAN> list backup;
RMAN> catalog start with '/home/oracle/fsbak/';
RMAN> recover database noredo;
SQL> alter database open;
7、实时同步开启实时同步. SQL> alter database recover managed standby database using current logfile disconnect from session;$ ps -ef | grepmrp
|