從備份集恢復歸檔日誌的測試與說明

 

 

當數據庫出現問題,但不需要restore只需recover時,發現要用到的archivelog已經備份並刪除了,因爲我們備份archivelog一般是採用delete input的,
這時先需要restore archivelog,然後才能做recover,下面介紹一下restore archivelog的用法:

 

 

restore archivelog後面可以跟的參數有"all, from, high, like, logseq, low, scn, sequence, time, until"

 

如果是RAC,需要恢復其中一個節點的某個歸檔,如下:

根據rac線程restore archivelog from logseq 6160 thread 2;

 

現在舉一列子說明:
1.列出已經備份的archivelog
list backup of archivelog all;
2.預覽恢復出程,但不真正恢復
可以在你執行恢復前先看看恢復過程,也可以驗證一下你的語法是否寫對
restore archivelog all preview; 即在你要執行的restore archivelog命令後加preview
restore archivelog sequence 18 preview;
3.恢復指定時間範圍的archivelog
3.1 顯示2008-08-13 10:00:00到2008-08-13 11:00:00之間的archivelog
list backup of archivelog time between "to_date('2008-08-13 10:00:00','yyyy-mm-dd hh24:mi:ss')" and "to_date('2008-08-13 11:00:00','yyyy-mm-dd hh24:mi:ss')";
3.2 預覽恢復2008-08-13 10:00:00到2008-08-13 11:00:00之間的archivelog
restore archivelog time between "to_date('2008-08-13 10:00:00','yyyy-mm-dd hh24:mi:ss')" and "to_date('2008-08-13 11::00','yyyy-mm-dd hh24:mi:ss')" preview;
3.3 真正恢復2008-08-13 10:00:00到2008-08-13 11:00:00之間的archivelog
restore archivelog time between "to_date('2008-08-13 10:00:00','yyyy-mm-dd hh24:mi:ss')" and "to_date('2008-08-13 11::00','yyyy-mm-dd hh24:mi:ss')"
4.恢復指定的archivelog
restore archivelog sequence 18; 恢復sequence爲18的archivelog
5.restore archivelog like恢復模糊查詢出來的archivelog,這個只能用於通過catalog的備份,用nocatalog的會報錯
restore archivelog like '%18%';
6.恢復指定sequence範圍的archivelog
restore archivelog from sequence 18 until sequence 20;
或restore archivelog low sequence 18 high sequence 20;
或restore archivelog low logseq 18 high logseq 20;
7.指定archivelog的恢復目的地,如你想把archivelog恢復到一個臨時目錄時有用,但這個必須包含在run{}裏面才能用
set archivelog destination to 'e:\temp';

以上基本上可以解決你恢復archivelog的需求,我是在10.2.0.4版本中測試通過的,歡迎大家補充,轉載請說明出處.

---------------------------------------------
以下部分是在本人正式環境中遇到的實際情況,非轉載:
備份日誌中有以下內容:
通道 t1: 正在指定備份集中的存檔日誌
輸入存檔日誌線程 =1 序列 =18070 記錄 ID=35794 時間戳=671966051
輸入存檔日誌線程 =1 序列 =18071 記錄 ID=35796 時間戳=671966351
輸入存檔日誌線程 =1 序列 =18072 記錄 ID=35798 時間戳=671966652
輸入存檔日誌線程 =1 序列 =18073 記錄 ID=35800 時間戳=671966952
輸入存檔日誌線程 =1 序列 =18074 記錄 ID=35802 時間戳=671967249
輸入存檔日誌線程 =1 序列 =18075 記錄 ID=35804 時間戳=671967550
輸入存檔日誌線程 =1 序列 =18076 記錄 ID=35806 時間戳=671967850
輸入存檔日誌線程 =1 序列 =18077 記錄 ID=35808 時間戳=671968151
輸入存檔日誌線程 =1 序列 =18078 記錄 ID=35810 時間戳=671968451

單獨恢復18071 到18076

    rman> run
    { allocate channel t1 type 'sbt_tape' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
    restore archivelog from logseq 18071 until logseq 18076 ;
    release channel t1;
    }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章