Oracle DataGuard歸檔日誌丟失處理方法

來源:互聯網
上載者:User

Oracle DataGuard歸檔日誌丟失處理方法

某資料庫配置了Physical DataGuard(以下簡稱dg),由於沒有檢查,所以在主庫上把歸檔日 刪除了,而備庫又沒有完全應用,所以導致備庫一直停留在之前的歸檔日誌中。

主庫檢查,發現dest_id為的25號日誌就丟失了.

PRIMARY> select dest_id,sequence#,applied,status,first_change#,next_change# from v$archived_log                         
  where sequence#>20 order by dest_id,sequence#; 


    DEST_ID  SEQUENCE# APPLIED S FIRST_CHANGE# NEXT_CHANGE#
 ---------- ---------- --------- - ------------- ------------
 1  21 NO D 1765541      1765764
 1  22 NO D 1765764      1768228
 1  23 NO D 1768228      1768269
 1  24 NO D 1768269      1768400
 1  25 NO X 1768400      1768516
 1  26 NO X 1768516      1768531
 1  27 NO X 1768531      1768611
 2  21 YES A 1765541      1765764
 2  22 YES A 1765764      1768228
 2  23 YES A 1768228      1768269
 2  24 NO A 1768269      1768400

    DEST_ID  SEQUENCE# APPLIED S FIRST_CHANGE# NEXT_CHANGE#
 ---------- ---------- --------- - ------------- ------------
 2  26 NO A 1768516      1768531
 2  27 NO A 1768531      1768611

所以備庫一直無法使用.這種情況下要麼就重做整個備庫,或是從備庫斷點的日誌那個時候起恢複資料庫.
由於資料庫比較大,決定採用第二種方案;

在備庫上,我們查看當前的資料檔案最大的SCN

STANDBY> select name,file#,checkpoint_change# from v$datafile order by checkpoint_change#;

NAME    FILE# CHECKPOINT_CHANGE#
 ------------------------------------------------------- ---------- ------------------
 /u01/app/Oracle/oradata/dc1stby/undotbs01.dbf 4      1768269
 /u01/app/oracle/oradata/dc1stby/sysaux01.dbf 3      1768269
 /u01/app/oracle/oradata/dc1stby/system01.dbf 1      1768269
 /u01/app/oracle/oradata/dc1stby/users01.dbf 6      1768269

在主庫上做一個增量SCN備份,起始的位置就是備庫資料檔案的最小SCN號.

[oracle@newplat ~]$ rman target / nocatalog

[oracle@newplat ~]$ $ORACLE_HOME/bin/rman target / nocatalog

 RMAN> run
 2> {
 3> allocate channel c3 device type disk;
 4>  backup as compressed backupset incremental from scn 1768269 database format '/home/oracle/bak/%U';
 5> release channel c3;
 6> }

 released channel: ORA_DISK_1
 allocated channel: c3
 channel c3: SID=42 device type=DISK
 .....................................................
 including current control file in backup set
 channel c3: starting piece 1 at 03-APR-16
 channel c3: finished piece 1 at 03-APR-16
 piece handle=/home/oracle/bak/0rr22q7u_1_1 tag=TAG20160403T022709 comment=NONE
 channel c3: backup set complete, elapsed time: 00:00:01
 Finished backup at 03-APR-16

備份完成後,我們通過SCP很快把備份檔案傳到備庫的機器上來

[oracle@newplat bak]$ scp *1_1 192.168.56.22:/home/oracle/bak

這時候我們需要關閉備庫,然把把執行個體啟動到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

執行個體啟動到mount狀態後,我們進入備庫的rman,這時候需要恢複控制檔案,原備庫的控制檔案因為
 包含了redo apply老的應用資訊所以不能用了.

 [oracle@dg2 bak]$ rman target / nocatalog

 RMAN> restore standby controlfile from '/home/oracle/bak/0rr22q7u_1_1';

 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 standby database;

Database altered.

資料庫mount起來後,我們返回到rman提示符,這個時候我們可以對傳過來的備份檔案並進行編目了.這樣我們在下一步操作中,就可以使用這些檔案來行恢複

RMAN> catalog start with '/home/oracle/bak';

searching for all files that match the pattern /home/oracle/bak

 List of Files Unknown to the Database
 =====================================
 File Name: /home/oracle/bak/08r1ekse_1_1
 File Name: /home/oracle/bak/0or22q7t_1_1
 File Name: /home/oracle/bak/0kr22phj_1_1
 File Name: /home/oracle/bak/0nr22pic_1_1
 File Name: /home/oracle/bak/09r1eku6_1_1
 File Name: /home/oracle/bak/0rr22q7u_1_1

 Do you really want to catalog the above files (enter YES or NO)? yes
 cataloging files...
 cataloging done

檔案編目後,我們就可以開始正式恢複資料庫了.

RMAN> recover database;

 Starting recover at 03-APR-16
 using channel ORA_DISK_1

 starting media recovery

.....................................

 media recovery complete, elapsed time: 00:03:01
 Finished recover at 03-APR-16

備庫完成恢複完成後,我們就可以啟動redo apply 了.

STANDBY> alter database recover managed standby database disconnect from session using current logfile;

 Database altered.

 STANDBY> select process,client_process,sequence#,status from v$managed_standby;

 PROCESS  CLIENT_P  SEQUENCE# STATUS
 --------- -------- ---------- ------------
 ARCH  ARCH    0 CONNECTED
 ARCH  ARCH    0 CONNECTED
 ARCH  ARCH    0 CONNECTED
 ARCH  ARCH    0 CONNECTED
 ARCH  ARCH    0 CONNECTED
 RFS  ARCH    0 IDLE
 RFS  LGWR  33 IDLE
 MRP0  N/A  33 WAIT_FOR_LOG

現在我們查看備庫狀態,MRP進程已經開始最新的日誌應用了.到此我們通過增量SCN備份和恢複來修複備庫歸檔日誌丟失的過程已經全部完成了。

 

Oracle 11gR2 在VMWare虛擬機器中安裝步驟

 

Debian 下 安裝 Oracle 11g XE R2

 

Oracle Data Guard 重要配置參數

 

基於同一主機配置 Oracle 11g Data Guard

 

探索Oracle之11g DataGuard

 

Oracle Data Guard (RAC+DG) 歸檔刪除策略及指令碼

 

Oracle Data Guard 的角色轉換

 

Oracle Data Guard的日誌FAL gap問題

 

Oracle 11g Data Guard Error 16143 Heartbeat failed to connect to standby 處理方法

 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.