DG由於網絡原因或者bug原因經常不同步,有時隔得時間久了,就會丟失歸檔日志,或者長時間的歸檔恢復較慢,有一種可以基於scn的方式來恢復DG庫,使用基於scn的增量備份來恢復standby庫可以節省大量時間,或者進行dg異常的重新同步。
1,查詢主庫和備庫的scn,redo號等信息,選取合適的scn號進行主庫的備份
--查詢DG端最低的scn,以下查詢結果應該相同 select to_char(current_scn) scn from v$database; select min(fhscn) from x$kcvfh; select distinct to_char(checkpoint_change#) from v$datafile_header order by 1; --以歸檔日志查詢相關scn select THREAD#,min(sequence#) from v$archived_log where applied='NO' group by THREAD#; select THREAD#,max(sequence#) from v$archived_log where applied='NO' group by THREAD#; SELECT thread#,SEQUENCE#,to_char(FIRST_CHANGE#) fc,to_char(NEXT_CHANGE#) nc FROM v$archived_log WHERE SEQUENCE# = 32995 ORDER BY 1,2;
2,主庫端基於scn的增量備份
RMAN> BACKUP INCREMENTAL FROM SCN <SCN from previous step> DATABASE FORMAT '/tmp/ForStandby_%U' tag 'FORSTANDBY' --or backup device type disk incremental from scn 11125946510 database format'/home/oracle/db_incre%U.bbk'; --or run { allocate channel t1 type 'sbt_tape' parms 'ENV=(NB_ORA_CLIENT=bossb1)'; allocate channel t2 type 'sbt_tape' parms 'ENV=(NB_ORA_CLIENT=bossb1)'; allocate channel t3 type 'sbt_tape' parms 'ENV=(NB_ORA_CLIENT=bossb1)'; allocate channel t4 type 'sbt_tape' parms 'ENV=(NB_ORA_CLIENT=bossb1)'; allocate channel t5 type 'sbt_tape' parms 'ENV=(NB_ORA_CLIENT=bossb1)'; allocate channel t6 type 'sbt_tape' parms 'ENV=(NB_ORA_CLIENT=bossb1)'; allocate channel t7 type 'sbt_tape' parms 'ENV=(NB_ORA_CLIENT=bossb1)'; allocate channel t8 type 'sbt_tape' parms 'ENV=(NB_ORA_CLIENT=bossb1)'; backup incremental from scn 12844051683640 database format 'forstandby_%u' tag 'forstandby'; backup current controlfile for standby format 'forstandbyctrl.bck' tag 'forstandby_cnt'; release channel t1; release channel t2; release channel t3; release channel t4; release channel t5; release channel t6; release channel t7; release channel t8; }
ALTER DATABASE CREATE standby controlfile AS '/home/oracle/standby.ctl';
3,傳輸文件到dg端,rman catalog start with
4,恢復控制文件,恢復數據庫
RMAN>restore controlfile from'/data/oracle/backup/restore/standby.ctl'; --mount database RMAN> RECOVER DATABASE NOREDO;
5,啟動同步進程,檢查同步狀態等。