Oracle DataGuard發生歸檔丟失增量備份恢復備庫
阿新 • • 發佈:2021-06-22
1.確定增量恢復起點SCN
有如下方法:
-
備庫檢視丟失的歸檔序列號
--備庫檢視丟失的歸檔號 SELECT * FROM V$ARCHIVE_GAP; --主庫執行,檢視SCN,146為第一個缺失歸檔的序列號 SELECT FIRST_CHANGE# FROM V$ARCHIVED_LOG WHERE SEQUENCE#=146;
-
備庫檢視當前的SCN
SELECT TO_CHAR(CURRENT_SCN) FROM V$DATABASE;
-
備庫檢視檔案的SCN
SELECT DISTINCT CHECKPOINT_CHANGE# FROM V$DATAFILE_HEADER;
在測試環境中,以上CURRENT_SCN為5156981,其他兩個都為5156982
2.增量備份
2.1.主庫執行增量備份
run{ allocate channel d1 type disk; allocate channel d2 type disk; backup as compressed backupset incremental from SCN 5156981 database format '/archlog/backup/standby_%d_%T_%U.bak' tag 'FOR STANDBY'; backup current controlfile for standby format '/archlog/backup/standby_%d_%T_%U_CTRL.bak'; release channel d1; release channel d2; }
2.2.傳送到備庫
scp * xxx.xxx.xxx.xxx:/archlog/backup/
3.備庫恢復
3.1.恢復控制檔案
資料庫至nomount狀態
alter database recover managed standby database cancel;
shutdown immediate;
startup nomount;
進入rman恢復
restore standby controlfile from '/archlog/backup/standby_DGTEST_20210621_0d01vmh7_1_1_CTRL.bak';
3.2.識別增量備份
資料庫至mount狀態
alter database mount;
識別備份
catalog start with '/archlog/backup';
3.3.查詢新增的檔案
如果沒有新增檔案,可以忽略此節
3.3.1.查詢檔案
SELECT * FROM V$DATAFILE_HEADER WHERE CREATION_CHANGE#>5156981;
3.3.2.修改備庫引數
alter system set standby_file_management = manual;
3.3.3.新增對應的檔案
SELECT 'alter database create datafile '''||name||''';' FROM V$DATAFILE_HEADER WHERE CREATION_CHANGE#>5156981;
3.3.4.修改備庫引數
alter system set standby_file_management = auto;
3.4.恢復備庫
recover database noredo
4.開啟資料庫日誌應用
alter database open read only;
alter database recover managed standby database disconnect;
5.測試並開啟全備
主庫新建一個表檢視備庫是否OK