dataguard中rman恢復的應用

myownstars發表於2012-03-12

RMAN透過db_unique_name把備份集同db關聯在一起,

RMAN uses the DB_UNIQUE_NAME initialization parameter to distinguish one database site from another database site. Thus, it is critical that the uniqueness of DB_UNIQUE_NAME be maintained in a Data Guard configuration,執行操作時需要使用FOR DB_UNIQUE_NAME與某個db進行關聯

 

dataguard中若一個standby執行了unregister命令,則其備份集仍可以被其他db使用

When a standby database is completely removed from a Data Guard environment, the database information in the recovery catalog can also be removed after you connect to another database in the same Data Guard environment. The backups that were associated with the database that was unregistered are still usable by other databases. You can associate these backups with any other existing database by using the CHANGE BACKUP RESET DB_UNIQUE_NAME command.

When the UNREGISTER DB_UNIQUE_NAME command is used with the INCLUDING BACKUPS option, the metadata for all the backup files associated with the database being removed is also removed from the recovery catalog.

 

 

主庫配置archived log的保留策略,有兩種方式可以用來節約主庫儲存空間

1 日誌一旦傳輸到備庫即刪除CONFIGURE ARCHIVELOG DELETION POLICY TO SHIPPED TO ALL STANDBY

2 日誌一旦已經應用到備庫即刪除CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY

 

 

恢復案例

利用備庫的檔案恢復主庫

1 rman登入備庫 

CONNECT TARGET sys@standby

2 auxiliary身份連線主庫

  CONNECT AUXILIARY sys@primary

3 備份資料檔案到主庫

  BACKUP AS COPY DATAFILE 2 AUXILIARY FORMAT '/disk9/df2copy.dbf';

4 rman登入主庫,進行識別恢復

   CONNECT TARGET sys@primary

     CONNECT CATALOG rman@catdb

   CATALOG DATAFILECOPY '/disk9/df2copy.dbf';

   RUN {

   SET NEWNAME FOR DATAFILE 2 TO '/disk9/df2copy.dbf';

   SWITCH DATAFILE 2;

 }

 

利用增量備份roll forward物理備庫

適用兩種情況:

1       備庫存在很大的lag,或者需要恢復的archivelog已被刪除

2       備庫的資料檔案存在nologging changes

 

步驟

1  停止備庫應用,檢視v$database.current_scn;若是因為nologging changes, 則查詢

SQL> SELECT FILE#, FIRST_NONLOGGED_SCN FROM V$DATAFILE WHERE FIRST_NONLOGGED_SCN > 0;

FILE#      FIRST_NONLOGGED_SCN

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

4              225979

5                    230184

 

2  rman登入主庫,執行主庫的增量備份;若是nologging changes,則只備份相應資料檔案

RMAN> BACKUP INCREMENTAL FROM SCN 225979 DATAFILE 4 FORMAT '/tmp/ForStandby_%U' TAG 'FORSTANDBY';

RMAN> BACKUP INCREMENTAL FROM SCN 230184 DATAFILE 5 FORMAT '/tmp/ForStandby_%U' TAG 'FORSTANDBY';

 

3 將備份集scp到備庫並catalog載入,然後執行report schema確認備份集已註冊至備庫

4  備庫執行recover redo

RMAN> STARTUP FORCE NOMOUNT;

RMAN> RESTORE STANDBY CONTROLFILE FROM TAG 'FORSTANDBY';

RMAN> ALTER DATABASE MOUNT;

RMAN> RECOVER DATABASE NOREDO;

 

然後驗證

SELECT FILE#, FIRST_NONLOGGED_SCN FROM V$DATAFILE WHERE FIRST_NONLOGGED_SCN > 0;

驗證無誤後開啟備庫redo apply

 

對於因為nologging導致的corrupted block,可以參照

 

 

 

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

相關文章