RMAN還原相關概念、spfile、controlfile恢複

來源:互聯網
上載者:User

1、還原(restore),是指訪問先前產生的備份組,從中得到一個或多個對象,然後在磁碟上的某個位置還原這些對象。
 恢複(recovery),是一個使資料庫與給定時間點相一致以保證能夠開啟這個資料庫的實際進程,該進程通常是通過應用重做(包括聯機重做日誌和歸檔重做日誌)來完成的。
 2、要開啟一個Oracle資料庫,要求這個資料庫與給定的時間狀態一致。
 3、Oracle通過檢查每個資料檔案頭中的當前SCN和控制檔案中的當前SCN是否一致來確定資料庫是否處於一致狀態。
 4、如果探索資料庫是不一致的,Oracle就需要判斷是否能夠基於聯機重做日誌來恢複這個資料庫,或者是否需要歸檔重做日誌來完成恢複。如果能夠使用聯機重做日誌來執行恢複操作,它就會執行災難恢複(或者在RAC環境中執行執行個體恢複操作),如果不能,它就會停止啟動進程,同時要求執行介質恢複操作。
 5、使用RMAN(不使用FRA)從自動備份中恢複spfile
 restore spfile from autobackup
 預設情況下,Oracle會尋找一個在過去10天內建立的控制檔案備份集,如果沒有找到在指定時間周期內建立的控制檔案備份集,就會產生一個錯誤。
 使用restore命令的maxseq和maxdays參數可以修改RMAN向後尋找控制檔案自動備份的時間周期。
 恢複樣本1
 set oracle_sid=recover
 rman target sys/robert
 set DBID = 2359725638;
 startup nomount;
 restore spfile from autobackup;
 shutdown immediate;
 恢複樣本2(指定路徑)
 set oracle_sid=recover
 rman target sys/robert
 set DBID = 2359725638;
 startup nomount;
 run
 {
 set controlfile autobackup format for device type disk to 'C:\oracle\backup\%F';
 allocate channel c1 device type disk;
 restore spfile from autobackup;
 }
 shutdown immediate;
 恢複樣本3(使用maxseq和maxdays)
 set oracle_sid=recover
 rman target sys/robert
 set DBID = 2359725638;
 startup nomount;
 run
 {
 set controlfile autobackup format for device type disk to 'C:\oracle\backup\%F';
 allocate channel c1 device type disk;
 restore spfile from autobackup maxseq 200 maxdays 100;
 }
 shutdown immediate;
 2、使用RMAN和FRA從自動備份中恢複spfile
 使用FRA情況下不需要設定DBID,也不用分配通道
 set oracle_sid=recover
 rman target sys/robert
 startup nomount;
 restore spfile from autobackup;
 shutdown immediate;
 3、從特定備份組中恢複spfile
 set oracle_sid=recover
 rman target sys/robert
 set DBID = 2359725638;
 startup nomount;
 run
 {
 allocate channel c1 device type disk;
 restore spfile from 'd:\backup\recover\C-2359725638-20131118-00';
 }
 shutdown immediate;
 4、使用恢複目錄恢複spfile
 set oracle_sid=recover
 rman target sys/robert catalog rcat_manager/password@robt
 startup nomount;
 restore spfile from autobackup;
 shutdown immediate;
 5、還原到pfile
 restore spfile to pfile 'd:\backup\test.ora';
 6、還原控制檔案(和恢複spfile差別不大)
 恢複樣本1
 set oracle_sid=recover
 rman target sys/robert
 set DBID = 2359725638;
 startup nomount;
 restore controlfile from autobackup;
 shutdown immediate;
 恢複樣本2(恢複較早的控制檔案備份,除了和恢複spfile一樣使用maxseq和maxdays以外還可以用until time)
 restore controlfile from autobackup until time "to_date('12/09/2005 13:00:00','MM/DD/YYYY HH24:MI:SS')";
 可以使用list backup of controlfile;
 7、恢複控制檔案後開啟資料庫
 恢複樣本1(假設在noarchivelog模式下運行)
 set oracle_sid=recover
 rman target sys/robert
 set DBID = 2359725638;
 startup nomount;
 restore database noredo;
 alter database open resetlogs;
 恢複樣本2(archivelog模式下運行)
 set oracle_sid=recover
 rman target sys/robert
 set DBID = 2359725638;
 startup nomount;
 restore database;
 alter database open resetlogs;
 8、使用catalog命令在控制檔案中註冊恢複相關檔案
 使用recovery area和db_recovery_file_dest關鍵字,使RMAN對整個FRA編寫目錄。
 catalog recovery area;
 如果沒有使用FRA,則使用start with文法。
 catalog start with 'c:\oracle\backups\testoem';
 9、將備份還原到其他位置(set newname for datafile和switch命令)
 startup nomount
 restore controlfile from autobackup;
 alter database mount;
 run
 {
 set newname for datafile '' to '';
 restore database;
 recover database noredo;
 switch datafile all;
 alter database open resetlogs;
 }
 10、不管是否運行在archivelog模式下,spfile和controlfile的恢複操作都是相同的。
 11、故障點恢複(完全恢複)需要聯機重做日誌是完整的,需要一個完整的controlfile。
 12、聯機資料表空間恢複
 sql 'alter tablespace users offline';
 restore tablespace users;
 recover tablespace users ;
 sql 'alter tablespace users online';

推薦閱讀:

RMAN 配置歸檔日誌刪除策略

Oracle基礎教程之通過RMAN複製資料庫

RMAN備份策略制定參考內容

RMAN備份學習筆記

OracleDatabase Backup加密 RMAN加密

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.