oracle基於SCN增量恢復

sjw1933發表於2022-10-08

基於 SCN 增量恢復

 

備庫停掉 MRP 程式

SQL> alter database recover managed standby database cancel;

 

1. 查詢最小 SCN

#### 生產庫 ####

SQL> select min(f.fhscn) from x$kcvfh f,v$datafile d where f.hxfil=d.file# and d.enabled!='READ ONLY';

 

MIN(F.FHSCN)

----------------

14847289822558

 

 

#### 備份庫 ####

SQL> select min(f.fhscn) from x$kcvfh f,v$datafile d where f.hxfil=d.file# and d.enabled!='READ ONLY';

 

MIN(F.FHSCN)

----------------

14846580672421

 

===> 14846580672421 <===

 

2. 在主庫上執行基於 SCN rman 備份

run{

allocate channel c1 type disk;

allocate channel c2 type disk;

backup incremental from scn 14846580672421 database format '/oradata/st_%U' tag '14846580672421';

###### 備份集壓縮

#######backup as compressed backupset incremental from scn 14846580672421 database format '/rman/bak_%U%t';

release channel c1;

release channel c2;

}

控制檔案備份

SQL>alter database create standby controlfile as '/tmp/rman/standby.ctl';

或使用 backup current controlfile 備份

RMAN> backup current controlfile for standby format '/backup/control%s.bak';

 

 

3. 把備份片拷到備庫

$ scp st* 10.87.250.91:/Tbackup/backup/

 

4. 控制檔案恢復

若之前用 rman 備份

備庫:

sql > shutdown immediate

sql > startup nomount 

rman > restore standby controlfile from '/Tbackup/backup/control65.bak';

rman > alter database mount;

 

 

5. 在備庫主機上,註冊備份片

RMAN> catalog backuppiece '/Tbackup/hdyy/st_crrl2dc5_1_1';

或者

RMAN> catalog start with '/Tbackup/backup'; 

 

RMAN> recover database noredo;

 

重建備庫controlfile

 

 

檢視資料檔案頭,驗證恢復情況

select file#, to_char(checkpoint_change#) from v$datafile_header;

 

 

6. 備庫重新啟動應用日誌

SQL>alter database recover managed standby database disconnect from session;

或者 SQL > alter database recover managed standby database using current logfile  disconnect from session;

 

主庫操作往備庫傳輸歸檔日誌

SQL>alter system set log_archive_dest_state_2 ='enable';

主備庫檢視歸檔日誌情況

SQL>archive log list;

主庫切下歸檔看是否用到備庫

Alter system switch lofile;


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

相關文章