Oracle rman catalog start with 導入備份集資訊測試

DB版本:11gR2
Catalog DB:有

我們的Oracle DB每天晚上都會利用rman進刪Full備份,當然也會把 Archive log備份起來。
這幾天試著用rman來還原前兩天的備份,操作的步驟到recover出現錯誤如下(未登入Catalog DB):
RMAN> recover database until time "to_date('20161001 12:00','yyyymmdd hh24:mi')";

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 03/10/2016 10:27:53
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 21002 and starting SCN of 20894105970


因為找不到 Archive log 記錄,所以造成失敗。

只要登入到Catalog DB,重新recover就會成功,因為 Catalog DB有完整的備份記錄。

其實還有另一種方法,利用指令將 Archive log 或較新的 Control file記錄導入到原本(較舊)的Control file內。
首先我把要還原的 Archive log檔案,由備份機複製到本機的/erptest/arch0目錄內,接著在RMAN內下達指令:

RMAN> catalog start with '/erptest/arch0/'
要注意的是路徑的最後面要加「/」,不然會找不到目錄,RMAN會自動分析指定目錄內所有的歸檔與Control file,再問你要不要導入進來。
searching for all files that match the pattern /erptest/arch0/
List of Files Unknown to the Database
=====================================
File Name: /erpdr/DB/test/PROD_arch_20161001_63753_1.arc

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

執行完成後,確認一下是否有記錄。
RMAN> list backup of archivelog all;

====================================================================================
BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
63744   17.86G     DISK        00:00:00     01-OCT-16     
        BP Key: 75128   Status: AVAILABLE  Compressed: NO  Tag: ARCHIVE LOG
        Piece Name: /erptest/arch0/PROD_arch_20161001_63753_1.arc

  List of Archived Logs in backup set 63744
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    21102   30902294784 30-SEP-16 30902366435 30-SEP-16
  1    21103   30902366435 30-SEP-16 30902684819 30-SEP-16
  1    21104   30902684819 30-SEP-16 30902971756 30-SEP-16
  1    21105   30902971756 30-SEP-16 30904151138 30-SEP-16
  1    21106   30904151138 30-SEP-16 30904962889 30-SEP-16
  1    21107   30904962889 30-SEP-16 30906159410 30-SEP-16
  1    21108   30906159410 30-SEP-16 30908070963 30-SEP-16
  1    21109   30908070963 30-SEP-16 30910343283 30-SEP-16
  1    21110   30910343283 30-SEP-16 30911293550 30-SEP-16
  1    21111   30911293550 30-SEP-16 30913640677 30-SEP-16

這樣就不須要登入catalog db,也可以利用Archive log來還原到指定的日期時間。

Windows 11安裝時跳過網路連線