问题描述 9.3日dg备库异常关闭,9.17日主库磁盘空间满,删除了归档日志,导致备库丢失了9.3号到9.17号得归档日志,所以当9.24日启动备库时报错 ORA-10458: standby database requires recovery ORA-01196: file 1 is inconsistent due to a failed media recovery session ORA-01110: data file 1: '/u01/oracle/oradata/system/system01.dbf' 解决办法: 1、在主库备份控制文件 backup current controlfile for standby format '/archivelog/0924_ctl_%U.bka' 2、已备库得最大SCN号在主库备份 在备库上执行 select name,to_char(checkpoint_change#) from v$datafile order by checkpoint_change#; NAME TO_CHAR(CHECKPOINT_CHANGE#) ---------------------------------------------------------------------------------------------------------------- /u01/app/oracle/oradata/TBSP_STAT_DATA_202009_01.dbf 446416908432 3、在主库上执行备份语句 rman target / run { allocate channel c1 device type disk; allocate channel c2 device type disk; allocate channel c3 device type disk; allocate channel c4 device type disk; allocate channel c5 device type disk; backup as compressed backupset incremental from scn 446416908432 database format '/archivelog/0924_%U.bka' tag 'forstandby'; release channel c1; release channel c2; release channel c3; release channel c4; release channel c5; } 4、把生成得备份文件都传到备库上 scp 0924* x.x.x.x:/tmp/ 5、 这时候我们需要关闭备库,然把把实例启动到nomount关态 STANDBY> shutdown immediate; ORA-01109: database not open Database dismounted. ORACLE instance shut down. STANDBY> startup nomount; ORACLE instance started. Total System Global Area 1224736768 bytes Fixed Size 2923824 bytes Variable Size 939524816 bytes Database Buffers 268435456 bytes Redo Buffers 13852672 bytes 6、在备库上执行restore,先恢复控制文件,在恢复数据文件 rman target / nocatalog RMAN> restore standby controlfile from '/tmp/0924_ctl_0rr22q7u_1_1.dbf'; Starting restore at 03-APR-16 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=23 device type=DISK ............................................ 很快控制文件就了恢复完成了,我们打开另一个窗口,通过sqlplus把备库以standby的方式mount起来 STANDBY> alter database mount; 恢复数据文件 先注册一下备份文件 rman> catalog start with '/tmp'; 开始恢复 run { allocate channel c1 device type disk; allocate channel c2 device type disk; allocate channel c3 device type disk; allocate channel c4 device type disk; allocate channel c5 device type disk; recover database; release channel c1; release channel c2; release channel c3; release channel c4; release channel c5; }
7、启动备库同步 SQL> alter database open read only; Database altered.
SQL> alter database recover managed standby database disconnect from session using current logfile; Database altered.
select process,client_process,sequence#,status from v$managed_standby; PROCESS CLIENT_P SEQUENCE# STATUS --------- -------- ---------- ------------ RFS ARCH 0 IDLE RFS UNKNOWN 0 IDLE RFS UNKNOWN 0 IDLE PROCESS CLIENT_P SEQUENCE# STATUS --------- -------- ---------- ------------ RFS LGWR 71162 IDLE MRP0 N/A 71158 APPLYING_LOG
现在我们查看备库状态,MRP进程已经开始最新的日志应用了.到此我们通过增量SCN备份和恢复来修复 备库归档日志丢失的过程已经全部完成了.
