Recovery Catalog

本文详细介绍了RMAN备份系统时如何利用Recovery Catalog进行管理,包括创建、使用Recovery Catalog的过程,以及其在数据库恢复、备份信息保存、查看备份信息等方面的优势。此外,还展示了如何在数据库不处于mount状态时查询备份信息,并提供了使用Recovery Catalog保存RMAN脚本的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、RecoveryCatalog

利用RMAN备份时,默认使用控制文件保存RMAN资料库,资料库包含备份集、镜像备份、归档日志的备份信息。默认控制文件保存这些信息是7天,可以通过参数control_file_record_keep_time查看。

SYS@orcl>show parametercontrol_file_record_keep_time;

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

control_file_record_keep_time integer 7

该参数最大可以设置为365,也就是说备份的信息最长可以保存365天,但是实际上我们并不会设置到这么大,因为该值设大后,控制文件保存的备份信息会很多,控制文件也会大很多,这样不利于控制文件的维护,如果真的需要备份信息保存很长时间,我们可以使用Recovery Catalog。

一般利用RMAN恢复数据库需要数据库在mount或者open状态使用RecoveryCatalog后数据库只要启动到mount状态,RMAN就可以得到备份信息。同时保存的备份信息不受control_file_record_keep_time参数的限制。RecoveryCatalog还可以保存RMAN脚本,查看任何时间点的表空间和数据库文件结构

二、创建和使用RecoveryCatalog

Recovery Catalog可以创建在目标数据库中,但是实际中为了保证catalog信息的安全性,应该把catalog放在不同服务器的另一个数据库上。以下例子使用名为'catadb'的数据库,TNS也为'catadb'。

创建RecoveryCatalog有以下5个步骤:

1.在catalog数据库创建表空间

[oracle@ora~]$sqlplussys/oracle@catadbassysdba

SQL*Plus: Release 11.2.0.3.0 Production on Sat Dec 29 15:44:15 2012

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SYS@catadb>createtablespacecata_tsdatafile'/u01/app/oracle/oradata/catadb/cata_ts01.dbf' size 100mautoextendon next 10m;

Tablespacecreated.

2.创建数据库用户

SYS@catadb>create usercatauseridentified by oracletemporarytablespacetempdefaulttablespacecata_ts quota unlimited oncata_ts;

User created.

3.将recovery_catalog_owner角色授予用户

SYS@catadb>grantrecovery_catalog_ownertocatauser;

Grant succeeded.

4.以新创建的用户通过rman连接到catalog数据库创建必须的对象

[oracle@ora~]$rmancatalogcatauser/oracle@catadb

Recovery Manager: Release 11.2.0.3.0 - Production on Sat Dec 29 15:56:46 2012

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

connected to recovery catalog database


RMAN> create catalog;

recovery catalog created

5.将目标数据库的信息注册到catalog

[oracle@ora~]$rmantarget sys/oracle@orclcatalogcatauser/oracle@catadb

Recovery Manager: Release 11.2.0.3.0 - Production on Sat Dec 29 15:59:51 2012

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

connected to target database: ORCL (DBID=1330943900)

connected to recovery catalog database

RMAN> register database;

database registered in recovery catalog

starting fullresyncof recovery catalog

fullresynccomplete

从此以后使用ramn连接目标数据库时使用catalog子句同时连接RecoveryCatalog才可以保证控制文件和catalog之间的信息同步。我们也可以在catalog数据库中执行手动同步

[oracle@ora~]$rmantarget sys/oracle@orclcatalogcatauser/oracle@catadb

Recovery Manager: Release 11.2.0.3.0 - Production on Sat Dec 29 16:08:19 2012

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

connected to target database: ORCL (DBID=1330943900)

connected to recovery catalog database

RMAN>resynccatalog;

starting fullresyncof recovery catalog

fullresynccomplete

再使用rman备份数据库时可以连接catalog数据库,这样所有的备份信息会保存在catalog数据库中

[oracle@ora~]$rmantarget sys/oracle@orclcatalogcatauser/oracle@catadb

……输出省略……

RMAN> backupdatafile1;

……输出省略……

三、RecoveryCatalog的其他功能

使用控制文件保存rman备份信息时,无法在数据库nomount状态查看备份信息,使用RecoveryCatalog后可以在nomount状态查看备份信息

[oracle@ora~]$rmantarget /

Recovery Manager: Release 11.2.0.3.0 - Production on Sat Dec 29 16:14:59 2012

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

connected to target database: ORCL (not mounted) ---目标数据库没有mount

RMAN> list backup; ---查询不到控制文件中保存的备份信息

using target database control file instead of recovery catalog

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of list command at 12/29/2012 16:15:03

ORA-01507: database not mounted

[oracle@ora~]$rmantarget / catalogcatauser/oracle@catadb

Recovery Manager: Release 11.2.0.3.0 - Production on Sat Dec 29 16:18:06 2012

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

connected to target database: ORCL (not mounted) ---'notmounted'表示目标数据库没有mount,但是连接到catalog数据库

connected to recovery catalog database


RMAN> list backup summary; ---连接到catalog数据库可以查询备份信息

List of Backups

===============

Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag

------- -- -- - ----------- --------------- ------- ------- ---------- ---

160 B F A DISK 29-DEC-12 1 1 NO TAG20121229T161103

161 B F A DISK 29-DEC-12 1 1 NO TAG20121229T161103

使用'reportschemaat'命令可以查看数据库数据文件的历史结构

RMAN> report schema; ---查看当前的数据库数据文件结构

Report of database schema for database withdb_unique_nameORCL

List of PermanentDatafiles

===========================

File Size(MB)Tablespace RBsegsDatafileName

---- -------- -------------------- ------- ------------------------

1 720 SYSTEM YES /u01/app/oracle/oradata/orcl/system01.dbf

2 580 SYSAUX NO /u01/app/oracle/oradata/orcl/sysaux01.dbf

3 105 UNDOTBS1 YES /u01/app/oracle/oradata/orcl/undotbs01.dbf

4 108 USERS NO /u01/app/oracle/oradata/orcl/users01.dbf

5 345 EXAMPLE NO /u01/app/oracle/oradata/orcl/example01.dbf


List of Temporary Files

=======================

File Size(MB)Tablespace Maxsize(MB)TempfileName

---- -------- -------------------- ----------- --------------------

1 29 TEMP 32767 /u01/app/oracle/oradata/orcl/temp01.dbf

RMAN> report schema at time "sysdate-interval '2' day"; ---查询两天前数据库数据文件结构

Report of database schema for database withdb_unique_nameORCL

List of PermanentDatafiles

===========================

File Size(MB)Tablespace RBsegsDatafileName

---- -------- -------------------- ------- ------------------------

1 720 SYSTEM YES /u01/app/oracle/oradata/orcl/system01.dbf

2 580 SYSAUX YES /u01/app/oracle/oradata/orcl/sysaux01.dbf

3 105 UNDOTBS1 YES /u01/app/oracle/oradata/orcl/undotbs01.dbf

4 108 USERS YES /u01/app/oracle/oradata/orcl/users01.dbf

RecoveryCatalog可以保存rman脚本。有两种方式创建rman脚本

1.执行createscript或者createglobalscritp命令

RMAN> create scriptsystemts_bak{

2> allocate channel c1 device type disk;

3> backuptablespacesystem;

4> }

created scriptsystemts_bak

2.从现有的文本文件中载入

RMAN> create global scriptsysauxts_bakfrom file '/home/oracle/sysauxts_bak.rman';

script commands will be loaded from file /home/oracle/sysauxts_bak.rman

created scriptsysauxts_bak


'createscript'和'createglobalscript'命令不同在于'createscript‘创建的脚本只能在当前目标数据库上执行,另外一个可以在所有已经注册的数据库上执行

可以执行'listscriptnames'或'listglobal scriptnames'查看脚本的名字,执行'printscript'或'printglobalscript'查看脚本内容。执行'run{execute script脚本名字}'或'run{execute global脚本名字}'调用脚本内容

四、删除注册数据库信息

要删除数据库的注册信息需要知道数据库的db_id和db_key,然后用catalog的管理用户登录catalog数据库执行过程dbms_rcvcat.unregisterdatabase(db_key,db_id)删除注册信息

[oracle@ora~]$rmantarget / catalogcatauser/oracle@catadb

Recovery Manager: Release 11.2.0.3.0 - Production on Sat Dec 29 17:26:25 2012

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

connected to target database: ORCL (not mounted)

connected to recovery catalog database

RMAN> list incarnation; ---查询db_key和db_id

List of Database Incarnations

DB Key IncKey DB Name DB ID STATUS Reset SCN Reset Time

------- ------- -------- ---------------- --- ---------- ----------

1 16 ORCL 1330943900 PARENT 1 17-SEP-11

1 2 ORCL 1330943900 CURRENT 995548 27-DEC-12

[oracle@ora~]$sqlpluscatauser/oracle@catadb;

SQL*Plus: Release 11.2.0.3.0 Production on Sat Dec 29 17:27:26 2012

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

CATAUSER@catadb>exec dbms_rcvcat.unregisterdatabase(1,1330943900); ---删除注册信息

PL/SQL procedure successfully completed.

[oracle@ora~]$rmantarget / catalogcatauser/oracle@catadb

Recovery Manager: Release 11.2.0.3.0 - Production on Sat Dec 29 17:32:08 2012

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

connected to target database: ORCL (DBID=1330943900)

connected to recovery catalog database

RMAN> list incarnation;

RMAN>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值