1. 程式人生 > >oracle dataguard archive gap後恢復

oracle dataguard archive gap後恢復

acl 導致 data code sco rom ann system pre

起因:源端數據庫應用程序邏輯錯誤,導致重大量重試回滾,日產生歸檔300GB,異地備份在10Mbps的網速下,產生了archive gap;
解決流程:
1 查出備庫當前的scn號

select current_scn from v$database;
1612480746

2 在主庫生成基於備庫scn的增量備份

--primary
show all;
run{
ALLOCATE CHANNEL d1 TYPE disk;
set limit channel d1 kbytes=104857600;
BACKUP  INCREMENTAL FROM SCN 1612480746 DATABASE FORMAT ‘J:\%U_for_stb.bk‘ include current controlfile for standby;
}

3 傳送日誌到備庫

--standby
catalog start with ‘e:\inc‘;

4 應用control file,增量備份集

restore standby controlfile to ‘e:\control01.ctl‘ ;
shutdown immediate;
copy   e:\control01.ctl   E:\ORADATA\TCIS\CONTROL01.CTL
copy    e:\control01.ctl  E:\ORADATA\TCIS\CONTROL02.CTL
copy    e:\control01.ctl  E:\ORADATA\TCIS\CONTROL03.CTL

recover database noredo;
報錯:

RMAN-03002: recover 命令 (在 07/08/2018 10:49:09 上) 失敗
RMAN-06094: 數據文件5必須重新存儲

啟動原先的備庫,select name from v$datafile
發現文件有重新rename的;有點梗;
5 修改數據文件位置

alter system set standby_file_management=manual;   
alter database rename file ‘E:\ORADATA\TCIS\UBSS_INDX01.DBF‘ to ‘d:\oradata\tcis\ubss_indx01.dbf‘;
alter database rename file ‘E:\ORADATA\TCIS\UBSS_INDX02.DBF‘ to ‘d:\oradata\tcis\ubss_indx02.dbf‘;

6 再次recover database noredo

又報錯,第16號文件不存在
RMAN-03002: recover 命令 (在 07/08/2018 10:49:09 上) 失敗
RMAN-06094: 數據文件16必須重新存儲

以老的控制文件啟動,發現第16號文件是之後添加的
7 主庫上備份16號文件
backup datafile 16 format ‘j:\16.bak‘;
8 備庫上恢復16文件

--primary
catalog start with ‘e:\inc‘;
restore datafile 16 ;
recover database noredo;
RMAN-03002: recover 命令 (在 07/07/2018 10:44:11 上) 失敗
ORA-19693: 已包括備份片段 E:\INC\CDT7BHIL_1_1_FOR_STB.BK
recover失敗,很名顯,這個16號文件是之後恢復的,其scn大於之前做的備份片集

9 清理無效的備份片,再次重復2之後的步驟,backup ,restore controlfile,rename datafile,recover database ;

10 恢復完成後檢查
復原參數
alter system set standby_file_management=auto;
啟動recover
alter database recover managed standby database disconnect;
檢查日誌應用情況

SQL> select status,blocks,process,sequence# from v$managed_standby;

STATUS           BLOCKS PROCESS    SEQUENCE#
------------ ---------- --------- ----------
CONNECTED             0 ARCH               0
CONNECTED             0 ARCH               0
CONNECTED             0 ARCH               0
CONNECTED             0 ARCH               0
IDLE              20480 RFS            45261
IDLE              20480 RFS            45262
IDLE                  0 RFS                0
APPLYING_LOG      81560 MRP0           45248

檢查歸檔,刪除已應用的歸檔

select a.thread#, a.sequence#, a.applied,a.name
from v$archived_log a, v$database d
where a.activation# = d.activation#
and a.applied=‘YES‘ order by 2;

oracle dataguard archive gap後恢復