rman catalog的创建和使用

创建

概述

使用RMAN 备份也分catalog 和nocatalog,就是是否使用恢复目录,如果不使用恢复目录,那么就是用control file作为catalog,每一次备份都要往控制文件里面写好多备份信息,控制文件里面会有越来越多的备份信息。因此,当使用rman nocatalog方式备份时,备份controlfile是非常重要的。 如果使用catalog模式,就需要句需要创建catalog目录。 当库比较多时,使用catalog也是比较方便的。

(oracle 使用catalog 来进行备份的话就需要先创建个catalog用户)

Catalog 则必须要首先要创建目录备份数据库,建立恢复目录。

另外,由于nocatalog时利用controlfile存放备份信息,建议将Oracle参数文件中的CONTROL_FILE_RECORD_KEEP_TIME值加大(缺省为7天), 该参数在$ORACLE_HOME/dbs/initSID.ora中(9i后也可能在spfile中,只能通过Oracle语句更改)。

使用本库作为恢复目录

1.创建恢复目录表空间
SQL> create tablespace tbs_rman datafile '/opt/oracle/oradata/orcl/tbs_rman01.dbf' size 200M autoextend on;

Tablespace created.

2.创建rman用户并授权
SQL> create user rman identified by rman temporary tablespace temp default tablespace tbs_rman quota unlimited on tbs_rman;
User created.
SQL> grant recovery_catalog_owner to rman;
Grant succeeded.
测试
SQL> conn rman/rman
Connected.
SQL> select * from session_privs;
PRIVILEGE
----------------------------------------
CREATE SESSION
ALTER SESSION
CREATE TABLE
CREATE CLUSTER
CREATE SYNONYM
CREATE VIEW
CREATE SEQUENCE
CREATE DATABASE LINK
CREATE PROCEDURE
CREATE TRIGGER
CREATE TYPE
11 rows selected.
SQL> select * from session_roles;
ROLE
------------------------------
RECOVERY_CATALOG_OWNER
SQL> 
3.连接恢复目录并创建恢复目录
[ oracle@hxy ~]$ rlwrap rman catalog rman/rman@orcl                                   //此处我连接的是我现有的当前数据库
Recovery Manager: Release 10.2.0.1.0 - Production on Sat Feb 23 23:19:19 2013
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to recovery catalog database
RMAN> create catalog tablespace tbs_rman;
recovery catalog created
4.连接到目标数据库及恢复目录
[oracle@hxy ~]$ rlwrap rman target / catalog rman/rman@orcl
Recovery Manager: Release 10.2.0.1.0 - Production on Sat Feb 23 23:29:03 2013
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to target database: ORCL (DBID=1334298584)
connected to recovery catalog database
RMAN> register database;            -- 将目标数据库注册到恢复目录
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
完成!!

使用自己新建的库

自己在主机上新建一个数据库,实例名为rman_db
确保能通过@连接
[oracle@hxy dbs]$ rlwrap sqlplus sys/oracle@rman_db as sysdb
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Feb 25 13:00:34 2013
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> select instance_name,status from v$instance;
INSTANCE_NAME    STATUS
---------------- ------------
rmandb           OPEN
[oracle@hxy dbs]$ rlwrap sqlplus sys/oracle@orcl as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Feb 25 12:59:52 2013
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> select instance_name,status from v$instance;
INSTANCE_NAME    STATUS
---------------- ------------
orcl             OPEN
(一下参考自 一沙弥的世界 博文)
1. 在存储恢复目录的数据库创建表空间用于存储恢复目录 schema 及恢复目录数据 ( 本文使用已经创建好的数据库 catadb 来存储恢复目录 )
[oracle@hxy ~]$ rlwrap sqlplus sys/oracle@rman_db as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Feb 25 13:06:52 2013
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/opt/oracle/oradata/rman_db/system01.dbf
/opt/oracle/oradata/rman_db/undotbs01.dbf
/opt/oracle/oradata/rman_db/sysaux01.dbf
/opt/oracle/oradata/rman_db/users01.dbf
SQL> create tablespace tbs_rman datafile '/opt/oracle/oradata/rman_db/tbs_rman01.dbf' size 20M autoextend on;
Tablespace created.

SQL> 
2.创建rman用户并授权
SQL> create user rman identified by rman temporary tablespace temp default tablespace tbs_rman quota unlimited on tbs_rman;
User created.
SQL> grant recovery_catalog_owner to rman;
Grant succeeded.
3.连接到恢复目录并创建恢复目录
[oracle@hxy ~]$ rlwrap rman catalog rman/rman@rman_db
Recovery Manager: Release 10.2.0.1.0 - Production on Mon Feb 25 13:27:44 2013
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to recovery catalog database
RMAN> create catalog tablespace tbs_rman;
recovery catalog created
RMAN> 
4.连接到目标数据库和恢复目录,并将目标数据库注册到恢复目录
[oracle@hxy ~]$ rlwrap rman target sys/oracle@orcl catalog rman/rman@rman_db
Recovery Manager: Release 10.2.0.1.0 - Production on Mon Feb 25 13:31:20 2013
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to
target database: ORCL (DBID=1334298584)
connected to recovery catalog database
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN> 
完成!!!

删除

SQL> drop user rman cascade;
User dropped.

RMAN> drop catalog;
recovery catalog owner is 
enter DROP CATALOG command again to confirm catalog removal

SQL> drop tablespace tbs_rman including contents and datafiles;
Tablespace dropped.

基于catalog RMAN 备份与恢复

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值