使用RMAN增量更新備份實現快速還原

hooca發表於2016-03-31
OS:Oracle Linux
DB: Oracle 11.2.0.4.0

增量更新備份:先做一個完整的映像備份,然後定期做增量更新備份,並將其應用到之前的完整映像備份,以獲得更新版備份。還原時直接切換到映像備份。

備份前最好設定RMAN的autobackup,可能需要恢復控制檔案。

在歸檔模式下的操作:

第一次備份:

RMAN下執行

點選(此處)摺疊或開啟

  1. backup incremental level 1 for recover of copy with tag 'FLASH' database plus archivelog;
# 備份映像預設在FRA中的datafile目錄下
第一次將會做完整映像備份。

第二次:

點選(此處)摺疊或開啟

  1. backup incremental level 1 for recover of copy with tag 'FLASH' database plus archivelog;
  2. recover copy of database with tag 'FLASH';

測試還原:
先啟動到mount模式,再切換資料庫,進入RMAN

點選(此處)摺疊或開啟

  1. shutdown immediate
  2. startup mount
  3. switch database to copy;
接下來,因為是在歸檔模式下,所以需要對資料庫recover,相關參考:http://blog.itpub.net/22621861/viewspace-1685967/

點選(此處)摺疊或開啟

  1. run {
    set until sequence 7 thread 1;
    recover database;
    alter database open resetlogs;
    }
此時,如果在RMAN下reporte obsolete,原來的資料檔案將作為過期的映像備份,可以delete obsolete刪除。


重新切換回原來的資料檔案路徑

先做映像備份

點選(此處)摺疊或開啟

  1. RMAN> backup as copy database format '/u01/app/oracle/oradata/prod/%U.dbf'
啟動到mount模式,切換資料庫

點選(此處)摺疊或開啟

  1. RMAN> shutdown immediate
  2. RMAN> startup mount
  3. RMAN> switch database to copy;
recover,open

點選(此處)摺疊或開啟

  1. RMAN> recover database;
  2. RMAN> alter database open;
另外,建議驗證備份

點選(此處)摺疊或開啟

  1. RMAN> validate datafilecopy all;
Starting validate at 2016-04-01 10:50:03
using channel ORA_DISK_1
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: including datafile copy of datafile 00005 in backup set
input file name=/u01/app/oracle/flash_recovery_area/PROD/datafile/o1_mf_sh_chspst8m_.dbf
channel ORA_DISK_1: including datafile copy of datafile 00004 in backup set
input file name=/u01/app/oracle/flash_recovery_area/PROD/datafile/o1_mf_users_chspy1xh_.dbf
channel ORA_DISK_1: including datafile copy of datafile 00001 in backup set
input file name=/u01/app/oracle/flash_recovery_area/PROD/datafile/o1_mf_system_chspzhjs_.dbf
channel ORA_DISK_1: including datafile copy of datafile 00002 in backup set
input file name=/u01/app/oracle/flash_recovery_area/PROD/datafile/o1_mf_sysaux_chsq095k_.dbf
channel ORA_DISK_1: including datafile copy of datafile 00003 in backup set
input file name=/u01/app/oracle/flash_recovery_area/PROD/datafile/o1_mf_undotbs1_chsq12rn_.dbf
channel ORA_DISK_1: validation complete, elapsed time: 00:00:26
List of Datafile Copies
=======================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
1    OK     0              16052        41600           4410291   
  File Name: /u01/app/oracle/flash_recovery_area/PROD/datafile/o1_mf_system_chspzhjs_.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              16866           
  Index      0              5514            
  Other      0              3168            


File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
2    OK     0              4459         41600           4410083   
  File Name: /u01/app/oracle/flash_recovery_area/PROD/datafile/o1_mf_sysaux_chsq095k_.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              16335           
  Index      0              15214           
  Other      0              5592            


File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
3    OK     0              1            34816           4410289   
  File Name: /u01/app/oracle/flash_recovery_area/PROD/datafile/o1_mf_undotbs1_chsq12rn_.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              0               
  Index      0              0               
  Other      0              34815           


File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
4    OK     0              63873        64000           3153      
  File Name: /u01/app/oracle/flash_recovery_area/PROD/datafile/o1_mf_users_chspy1xh_.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              0               
  Index      0              0               
  Other      0              127             


File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
5    OK     0              19125        239232          4409306   
  File Name: /u01/app/oracle/flash_recovery_area/PROD/datafile/o1_mf_sh_chspst8m_.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              179405          
  Index      0              38502           
  Other      0              2200            


Finished validate at 2016-04-01 10:50:29
最後,可以delete obsolete,刪除過期備份。

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

相關文章