使用RMAN恢复目录(catalog)解析

首先理解什么是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

本文转自ICT时空 dbasdk博客,原文链接:使用RMAN恢复目录(catalog)解析 ,如需转载请自行联系原博主。

上一篇:【SVN】基础命令使用详解


下一篇:smartassembly 使用指南