使用RMAN恢復目錄(catalog)解析

dbasdk發表於2014-08-22
首先理解什麼是catalog 恢復目錄,實際上就是把資料庫的一部分分出來作為catalog,來長時間存備份資訊,在實際生產中,有時候會遇到要恢復資料庫到一年或是更長時間之前的狀態,我們知道控制檔案存在很多重要的資料庫結構資訊,但是你的控制檔案早已經被覆蓋,你就不能完成任務,而catalog就不一樣了,它可以儲存很長時間,當然它也不只是可以存控制檔案,也可以存別的備份副本,你可以把它簡單的理解成儲存時間長的控制檔案,已經在控制檔案清除的資訊,重新載入回來。
1,建立恢復目錄所有者預設表空間
SYS@ENMOEDU> create tablespace ts_catalog datafile '/u01/app/oracle/oradata/ENMOEDU/ts_catalog.dbf' size 15m; 

Tablespace created.
2,建立恢復目錄所有者  
SYS@ENMOEDU> create user rcower identified by oracle default tablespace ts_catalog ; 

User created.
SYS@ENMOEDU> grant connect,resource ,recovery_catalog_owner to rcower;               

Grant succeeded.
3.建立恢復目錄
[oracle@ENMOEDU ~]$ rman catalog rcower/oracle@ENMOEDU             #catalog庫連線到另一個目標資料庫的的網路服務名(就是tnsname.ora 中開頭的名字)為ENMOEDU

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Aug 15 00:37:55 2014 

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. 

connected to recovery catalog database 

RMAN> create catalog;    #自動建立了恢復目錄相關的表,

recovery catalog created
註冊目標資料庫            註冊之後目標資料庫原檔案會同步到catalog  
[oracle@ENMOEDU ~]$ rman target sys/oracle@ENMOEDU catalog rcower/oracle@ENMOEDU

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Aug 15 00:47:57 2014 

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. 

connected to target database: ENMOEDU (DBID=87396644) 
connected to recovery catalog database
RMAN> register database; 

database registered in recovery catalog 
starting full resync of recovery catalog 
full resync complete 
檢視已經註冊的目標庫
[oracle@ENMOEDU ~]$ sqlplus rcower/oracle@ENMOEDU                     

SQL*Plus: Release 11.2.0.3.0 Production on Fri Aug 15 00:51:27 2014 

Copyright (c) 1982, 2011, Oracle. All rights reserved. 


Connected to: 
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production 
With the Partitioning, OLAP, Data Mining and Real Application Testing options 

RCOWER@ENMOEDU> SELECT * FROM RC_DATABASE; 

DB_KEY DBINC_KEY DBID NAME RESETLOGS_CHANGE# RESETLOGS 
---------- ---------- ---------- -------- ----------------- --------- 
1 2 87396644 ENMOEDU 1 07-OCT-13
從恢復目錄中登出目標資料庫
oracle@ENMOEDU ~]$ rman target sys/oracle@ENMOEDU catalog rcower/oracle@ENMOEDU;             #目標庫和catalog庫可以為同一個庫,但是實際上是沒有意義的,因為你庫打不開時,是無法使用catalog的

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Aug 15 00:47:57 2014 

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. 

connected to target database: ENMOEDU (DBID=87396644) 
connected to recovery catalog database
RMAN> unregister database; 
 將其他備份副本匯入到恢復目錄,
oracle@ENMOEDU ~]$ rman target sys/oracle@ENMOEDU catalog rcower/oracle@ENMOEDU;   
Recovery Manager: Release 11.2.0.3.0 - Production on Fri Aug 15 00:47:57 2014 

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. 

connected to target database: ENMOEDU (DBID=87396644) 
connected to recovery catalog database
將一個檔案匯入恢復目錄  
RMAN> catalog backuppiece                               '/u01/app/oracle/fast_recovery_area/ENMOEDU/backupset/2014_08_16/o1_mf_nnndf_TAG20140816T113253_9yxn76sb_.bkp';
using target database control file instead of recovery catalog
cataloged backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/ENMOEDU/backupset/2014_08_16/o1_mf_nnndf_TAG20140816T113253_9yxn76sb_.bkp RECID=26 STAMP=855748159
如果使用了快速恢復區,可以這樣一次性匯入。
RMAN> catalog recovery area noprompt;
searching for all files in the recovery area
no files found to be unknown to the database
List of files in Recovery Area not managed by the database
==========================================================
File Name: /u01/app/oracle/fast_recovery_area/ENMOEDU/control02.ctl
  RMAN-07526: Reason: File is not an Oracle Managed File
number of files not managed by recovery area is 1, totaling 9.38MB

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

相關文章