利用增量備份恢復因歸檔丟失造成的DG gap

abin1703發表於2017-05-24
利用增量備份恢復因歸檔丟失造成的DG gap


data guard歸檔出現gap,悲劇的是丟失的歸檔在主庫上被rman備份時刪除了,丟失的歸檔大約有20幾個,資料庫大小約2T,如果重建DG將非常耗時間,因此決定利用增量備份的方式恢復DG,主要步驟如下:


0、檢視備份庫歸檔應用
SQL> select sequence#,applied from v$archived_log;






1.備份備庫spfile檔案
SQL> create pfile='/home/ora/pfileRdg.ora' from spfile;


2、檢視當前備庫scn
SQL> select to_char(current_scn) from v$database;
TO_CHAR(CURRENT_SCN)
----------------------------------------
19652214434




3、檢視缺失的archivelog
SQL> select * from v$archive_gap;


   THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#
---------- ------------- --------------
         1        160163         160170
         2        151303         151309




4、在主庫執增量備份




[ora@jzhRAC1 ~]$ rman target /


Recovery Manager: Release 10.2.0.4.0 - Production on Sat May 23 18:10:52 2015


Copyright (c) 1982, 2007, Oracle.  All rights reserved.


connected to target database: JZH (DBID=2072634265)
RMAN> run
 {
 allocate channel d1 type disk;
 allocate channel d2 type disk;
 allocate channel d3 type disk;
 backup as compressed backupset incremental from SCN 19652214434 database format '/home/ora/full_db_%d_%T_%s.bak' include current controlfile for standby filesperset=5 tag 'FOR STANDBY';
 release channel d1;
 release channel d2;
 release channel d3;
 }


5、將備份傳至備庫                                                  
scp full_db_JZH_20150523_*.bak 192.168.110.115:~/20150523_recover/




6、恢復備庫                                                                  
[ora@jzhDG ~]$ rman target /                                                 
                                                                             
Recovery Manager: Release 10.2.0.4.0 - Production on Sat May 23 20:17:59 2015
                                                                             
Copyright (c) 1982, 2007, Oracle.  All rights reserved.                      
                                                                             
connected to target database: JZH (DBID=2072634265, not open)                
                                                                             
RMAN> catalog start with '/home/ora/20150523_recover';          




[ora@jzhDG ~]$ rman target /                                                 
                                                                         
Recovery Manager: Release 10.2.0.4.0 - Production on Sat May 23 20:25:44 2015
                                                                                      
Copyright (c) 1982, 2007, Oracle.  All rights reserved.                      
                                                                         
connected to target database: JZH (DBID=2072634265, not open)                
                                                                         
RMAN> run                                                                    
 {                                                                         
 allocate channel d1 type disk;                                            
 allocate channel d2 type disk;                                            
 allocate channel d3 type disk;                                            
 restore standby controlfile to '/home/ora/control01.ctl';                 
 recover database noredo;                                                  
 release channel d1;                                                       
 release channel d2;                                                       
release channel d3;                                                      
 }      
 
 如果報下面的錯誤。(只擷取了部分錯誤),我們可以重啟資料庫解決。
restore not done; all files readonly, offline, or already restored
Finished restore at 01-APR-12
 
Starting recover at 01-APR-12
released channel: dsk0
released channel: dsk1
released channel: dsk2
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 04/01/2012 23:14:12
ORA-01219: database not open: queries allowed on fixed tables/views only
 
 7、關閉備庫,將恢復出來的control01.ctl覆蓋備庫控制檔案  
 [ora@jzhDG ~]$ cp control01.ctl /oradata/JZH/standby.ctl
 
 8、啟動備庫至mount狀態                   
 SQL> startup mount                       
 ORACLE instance started.                 
 Total System Global Area 1795162112 bytes
 Fixed Size                  2084648 bytes
 Variable Size             301990104 bytes
 Database Buffers         1476395008 bytes
 Redo Buffers               14692352 bytes                                                                  
 Database mounted. 
 
 9、檢視gap                       
 SQL> select * from v$archive_gap;
 no rows selected                 
 
10、開啟備庫recover模式                                        
SQL> recover managed standby database disconnect from session; 
Media recovery complete.                                       
 
11、Alter database recover managed standby database cancel;
12、alter database open;
13、SQL> recover managed standby database disconnect from session;    


檢視備庫的歸檔應用狀態。                     
Select sequence#,applied from v$archived_log;


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30345407/viewspace-2139811/,如需轉載,請註明出處,否則將追究法律責任。

相關文章