rman 增量恢複 dg gap後 主庫添加新資料檔案,rmangap

來源:互聯網
上載者:User

rman 增量恢複 dg gap後 主庫添加新資料檔案,rmangap


1) On the standby database, 關閉 (MRP)
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;


2) On the STANDBY DATABASE, 擷取備庫最小scn值,用作主庫增量備份點 :
col MIN(CHECKPOINT_CHANGE#) for 999999999999999999
col CURRENT_SCN for 99999999999999999
SELECT CURRENT_SCN FROM V$DATABASE;


select min(checkpoint_change#) from v$datafile_header;
CHECKPOINT_CHANGE#
---------------------
3162298


col current_scn for 999999999999999
 SELECT CURRENT_SCN FROM V$DATABASE;
 
 select min(fhscn) from x$kcvfh;
 
 select min(f.fhscn) from x$kcvfh f, v$datafile d
      where f.hxfil =d.file# and d.enabled != 'READ ONLY' ;


取最小scn


3)  在主庫確定dg gap後新添加的資料檔案(scn 基於備庫的最小scn) :
SQL> SELECT FILE#, NAME FROM V$DATAFILE WHERE CREATION_CHANGE# > <SCN_NUMBER_FROM_STEP 2>;


4) 使用rman 建立相應資料檔案備份,和全庫基於scn 的增量備份,standb 控制檔案:
RMAN> backup datafile #, #, #, # format '/tmp/ForStandby_%U' tag 'FORSTANDBY';
RMAN> backup incremental from SCN 3162298 database format '/tmp/ForStandby_%U' tag 'FORSTANDBY';
RMAN> backup current controlfile for standby format '/tmp/ForStandbyCTRL.bck';



 5) 把備份結果拷貝到備庫
scp /tmp/ForStandby_* standby:/tmp


 6)恢複新產生的standby 控制檔案,並註冊拷過來的備份片:
RMAN> shutdown;
RMAN> startup nomount;
RMAN> restore standby controlfile from '/tmp/ForStandbyCTRL.bck';
RMAN> alter database mount;


-----註冊拷過來的備份片
RMAN> CATALOG START WITH '/tmp/ForStandby'; 

using target database control file instead of recovery catalog 
searching for all files that match the pattern /tmp/ForStandby 


List of Files Unknown to the Database 
===================================== 
File Name: /tmp/ForStandby_2llixora4_1_1 
File Name: /tmp/ForStandby_2mlixora8_1_1 


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


List of Cataloged Files 
======================= 
File Name: /tmp/ForStandby_2llixora4_1_1 
File Name: /tmp/ForStandby_2mlixora8_1_1



 7) restore missing datafiles:
這裡可能會有問題,當主庫新添加的資料檔案沒有資料時,ramn 備份產生的是備份組只100多kb,貌似在使用


catalog start with 時oracle 沒法識別到。
不過沒關係,我們可以直接手工註冊:
CATALOG BACKUPPIECE '/tmp/01dmsbj4_1_1.bcp’; 

run
{
set newname for datafile 9 to '+DISKGROUP';
set newname for datafile 8 to '+DISKGROUP';
set newname for datafile 11 to '+DISKGROUP';
#set newname for datafile 12 to '/oradata/datafile/lixora.dbf';
restore datafile 9,8,11,....;
}



8)更新備庫 stndby 控制檔案中資料檔案的路徑 .
使用 catalog 命令更新資料檔案路徑(備庫和主庫資料檔案名,路徑不同的資料檔案)


RMAN> CATALOG START WITH '+DATA/lixora/datafile/'; 
or
RMAN> CATALOG START WITH '/oradata/lixora/datafile/'; 

List of Files Unknown to the Database 
===================================== 
File Name: +data/lixora/DATAFILE/SYSTEM.309.685535773 
File Name: +data/lixora/DATAFILE/SYSAUX.301.685535773 
File Name: +data/lixora/DATAFILE/UNDOTBS1.302.685535775 
File Name: +data/lixora/DATAFILE/SYSTEM.297.688213333 
File Name: +data/lixora/DATAFILE/SYSAUX.267.688213333 
File Name: +data/lixora/DATAFILE/UNDOTBS1.268.688213335 

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

List of Cataloged Files 
======================= 
File Name: +data/lixora/DATAFILE/SYSTEM.297.688213333 
File Name: +data/lixora/DATAFILE/SYSAUX.267.688213333 
File Name: +data/lixora/DATAFILE/UNDOTBS1.268.688213335




---這一步等效於 alert database datafile rename ,這一步才真正去更新standby 控制檔案中的資料檔案資訊:
RMAN> SWITCH DATABASE TO COPY; 


datafile 1 switched to datafile copy "+DATA/lixora/datafile/system.297.688213333" 
datafile 2 switched to datafile copy "+DATA/lixora/datafile/undotbs1.268.688213335" 
datafile 3 switched to datafile copy "+DATA/lixora/datafile/sysaux.267.688213333"
 
9) 使用增量備份恢複 備庫,noredo表示不應用redo or 歸檔:
RMAN> RECOVER DATABASE NOREDO; 

starting recover at 03-JUN-09 
allocated channel: ORA_DISK_1 
channel ORA_DISK_1: sid=28 devtype=DISK 
channel ORA_DISK_1: starting incremental datafile backupset restore 
channel ORA_DISK_1: specifying datafile(s) to restore from backup set 
destination for restore of datafile 00001: +DATA/lixora/datafile/system.297.688213333 
destination for restore of datafile 00002: +DATA/lixora/datafile/undotbs1.268.688213335 
destination for restore of datafile 00003: +DATA/lixora/datafile/sysaux.267.688213333 
channel ORA_DISK_1: reading from backup piece /tmp/ForStandby_2llixora4_1_1 
channel ORA_DISK_1: restored backup piece 1 
piece handle=/tmp/ForStandby_2llixora4_1_1 tag=FORSTANDBY 
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02 
Finished recover at 03-JUN-09


10) 【可選】配置閃回
If the STANDBY database needs to be configured for FLASHBACK use the below step to enable.
SQL> ALTER DATABASE FLASHBACK OFF; 
SQL> ALTER DATABASE FLASHBACK ON;


11) 清理所有的standby redolog ,建議清理


SQL> ALTER DATABASE CLEAR LOGFILE GROUP 1; 
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 2; 
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 3;
....

12) On the STANDBY database, 啟動MRP
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;


 This note assumes all files are at the same recovery scn or very close. 
If nologging operations have been made or files are at differnt or widely varying scns see the 

online documentation:
10.2:  http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/scenarios.htm#CIHIAADC
11.1:  http://download.oracle.com/docs/cd/B28359_01/server.111/b28294/rman.htm#SBYDB00759
11.2: http://download.oracle.com/docs/cd/E11882_01/server.112/e17022/rman.htm#CIHIAADC

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.