DG歸檔日誌缺失恢復

wangbinneuq發表於2020-11-17
  1. 主資料庫或者其他備庫的歸檔日誌還存在的恢復方式:歸檔直接恢復方式


    1.1 copy 主庫上的歸檔日誌至備庫,如果ASM磁碟先透過rman方式copy至檔案系統

    RMAN>copy archivelog '+data/orcl/ARCHIVELOG/2020_03_24/thread_1_seq_328729.4592.939510649' to'/home/oracle/archivelog/thread_1_seq_328729.4592.939510649';

     1.2 備機註冊archivelog到資料庫control file中

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

     1.3 啟動備機執行recover,執行實時應用日誌

    ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

     1.4 確認日誌歸檔應用已啟動,至此DG已恢復同步

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


  2. 主資料庫或者其他備庫的歸檔日誌已丟失的恢復方式:增量備份恢復方式

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

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

    TO_CHAR(CURRENT_SCN)
    ----------------------------------------
    145215070

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

    4、在主庫執增量備份

RMAN> run
 {
 allocate channel d1 type disk;
 allocate channel d2 type disk;
backup as compressed backupset incremental from SCN 145215070 database format '/home/oracle/full_db_%d_%T_%s.bak' include current controlfile for standby filesperset=5 tag 'FOR STANDBY';
release channel d1;
release channel d2;
}

        5、將備份傳至備庫
        scp full_db_orcl_xxxx_*.bak 192.168.1.100:~/xxxx_recover/ 
        6、註冊備份檔案,恢復備庫

RMAN> catalog start with '/home/ora/20150523_recover';


RMAN> 

run
{
allocate channel d1 type disk;
allocate channel d2 type disk;
restore standby controlfile to '/home/oracle/control01.ctl';
recover database noredo;
release channel d1;
release channel d2;

}

        7、關閉備庫,將恢復出來的control01.ctl覆蓋備庫控制檔案
        $ cp control01.ctl /oradata/orcl/standby.ctl
        8、啟動備庫至mount狀態
        SQL> startup mount

        9、檢視gap
        SQL> select * from v$archive_gap;
        
        10、開啟備庫recover模式
        SQL> alter database recover managed standby database disconnect from session;
        Media recovery complete.

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

相關文章