oralce 11g OCM之管理恢复目录
一:11g 版本中catalog的创建以及数据库的注册方式几乎和10g一模一样,如下:
1.创建catalog存放数据的表空间
create tablespace cat_tbs datafile ‘/data01/cat_tbs01.dbf’ size 10M autoextend on next 10M maxsize 500m;
2.创建catalog用户
create user rman identified by oracle default tablespace cat_tbs quota unlimited on cat_tbs;
grant recovery_catalog_owner to rman;
3.创建catalog并注册数据库
[oracle@luda 21:40:23|/oracle/product/11.2/network/admin]rman catalog rman/oracle@luda
Recovery Manager: Release 11.2.0.1.0 – Production on Thu Nov 15 21:40:27 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to recovery catalog database
RMAN>
RMAN> create catalog;recovery catalog created
RMAN> exit
Recovery Manager complete.
[oracle@luda 21:41:54|/oracle/product/11.2/network/admin]rman target / catalog rman/oracle@ludaRecovery Manager: Release 11.2.0.1.0 – Production on Thu Nov 15 21:42:08 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: LUDA (DBID=518309061)
connected to recovery catalog databaseRMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync completeRMAN> report schema;
Report of database schema for database with db_unique_name LUDA
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
—- ——– ——————– ——- ————————
1 700 SYSTEM YES /data01/system01.dbf
2 490 SYSAUX NO /data01/sysaux01.dbf
3 90 UNDOTBS1 YES /data01/undotbs01.dbf
4 5 USERS NO /data01/users01.dbf
5 100 EXAMPLE NO /data01/example01.dbf
6 10 CAT_TBS NO /data01/cat_tbs01.dbfList of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
—- ——– ——————– ———– ——————–
1 29 TEMP 32767 /oracle/oradata/LUDA/datafile/o1_mf_temp_8b3t8vw4_.tmpRMAN>
二:11g新特性 虚拟恢复目录
《Backup and Recovery User’s Guide》第13章 — Creating and Managing Virtual Private Catalogs
Catalog用来管理存储多个数据库的备份信息,Rman脚本等,在11g中ORACLE推出关于RMAN catalog的一个新特性Virtual Private Catalogs,相对catalog用来管理多个数据库备份等相关信息,Virtual Private Catalogs的主要作用是一个Virtual Private Catalogs对应一个数据库的DBA,在管理的时候可以避免catalog恢复时候导致其他数据库的相关备份信息,脚本等丢失,而每一个Virtual Private Catalogs可以把变动只会针对对应管理员管理的数据库,而不是所有的数据库。一个catalog下不限制Virtual Private Catalog的个数,Virtual Private Catalogs的归属用户和Catalog的归属用户必须不同。
创建虚拟私有目录服务步骤
1.创建相关表空间
SQL> create tablespace vptbs datafile ‘/data01/vptbs01.dbf’ size 50M;
Tablespace created.
2.创建相关用户
SQL> create user luda_vp identified by oracle default tablespace vptbs quota unlimited on vptbs;
User created.
3.给予用户以及catalog权限
给予用户数据库权限
SQL> grant recovery_catalog_owner to luda_vp;
Grant succeeded.
赋予catalog权限
[oracle@luda 23:03:24|~]rman catalog rman/oracle@luda
Recovery Manager: Release 11.2.0.1.0 – Production on Tue Nov 20 23:03:43 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to recovery catalog database
RMAN> grant catalog for database luda to luda_vp;
Grant succeeded.
RMAN> grant register database to luda_vp;
Grant succeeded.
RMAN>
4.使用虚拟目录用户登陆rman创建虚拟目录
[oracle@luda 23:06:18|~]rman catalog luda_vp/oracle@luda
Recovery Manager: Release 11.2.0.1.0 – Production on Tue Nov 20 23:06:35 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to recovery catalog database
RMAN> create virtual catalog;
found eligible base catalog owned by RMAN
created virtual catalog against base catalog owned by RMAN
5.移除虚拟目录用户权限
使用catalog用户登陆rman
[oracle@luda 23:10:28|~]rman catalog rman/oracle@luda
Recovery Manager: Release 11.2.0.1.0 – Production on Tue Nov 20 23:10:45 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to recovery catalog database
RMAN>
使用revoke命令移除相关权限
RMAN> revoke catalog for database luda from luda_vp
2> ;Revoke succeeded.
RMAN> revoke register database from luda_vp;
Revoke succeeded.
RMAN>
6.删除虚拟目录
使用虚拟目录用户登陆rman,执行删除操作
[oracle@luda 23:14:39|~]rman catalog luda_vp/oracle@luda
Recovery Manager: Release 11.2.0.1.0 – Production on Tue Nov 20 23:14:53 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to recovery catalog database
recovery catalog is not installedRMAN> drop catalog;
recovery catalog owner is LUDA_VP
enter DROP CATALOG command again to confirm catalog removalRMAN> drop catalog;
virtual catalog dropped
三.catalog的迁移以及删除
catalog的信息可以在用户之间进行迁移,可以是同库的用户也可以是不同库的用户。
通过import catalog相关命令,可以指定需要导入信息的实例的DBID,DB_NAME等。
1.首先测试为同库用户:
在luda实例下创建另外一个catalog用户:
[oracle@luda 21:58:08|~]sq
SQL*Plus: Release 11.2.0.1.0 Production on Wed Nov 21 21:58:10 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> create user rman1 identified by oracle default tablespace cat_tbs quota unlimited on cat_tbs;
User created.
SQL> grant recovery_catalog_owner to rman1;
Grant succeeded.
使用rman1用户创建catalog
[oracle@luda 22:02:59|~]rman catalog rman1/oracle@luda
Recovery Manager: Release 11.2.0.1.0 – Production on Wed Nov 21 22:03:10 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to recovery catalog database
RMAN> create catalog;
recovery catalog created
导入rman用户管理的catalog 指定数据库实例为luda
[oracle@luda 22:06:35|~]rman catalog rman1/oracle@luda
Recovery Manager: Release 11.2.0.1.0 – Production on Wed Nov 21 22:06:42 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to recovery catalog database
RMAN> import catalog rman/oracle@luda db_name=luda;
Starting import catalog at 21-NOV-12
connected to source recovery catalog database
import validation complete
database unregistered from the source recovery catalog
Finished import catalog at 21-NOV-12
查询导入后rman和rman1用户catalog信息
[oracle@luda 22:11:28|~]rman target/ catalog rman/oracle@luda
Recovery Manager: Release 11.2.0.1.0 – Production on Wed Nov 21 22:11:48 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: LUDA (DBID=518309061)
connected to recovery catalog databaseRMAN> report schema;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of report command at 11/21/2012 22:12:08
RMAN-06004: ORACLE error from recovery catalog database: RMAN-20001: target database not found in recovery catalogRMAN> exit
Recovery Manager complete.
[oracle@luda 22:12:12|~]rman target/ catalog rman1/oracle@ludaRecovery Manager: Release 11.2.0.1.0 – Production on Wed Nov 21 22:12:15 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: LUDA (DBID=518309061)
connected to recovery catalog databaseRMAN> report schema;
starting full resync of recovery catalog
full resync complete
Report of database schema for database with db_unique_name LUDAList of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
—- ——– ——————– ——- ————————
1 700 SYSTEM YES /data01/system01.dbf
2 500 SYSAUX NO /data01/sysaux01.dbf
3 90 UNDOTBS1 YES /data01/undotbs01.dbf
4 5 USERS NO /data01/users01.dbf
5 100 EXAMPLE NO /data01/example01.dbf
6 10 CAT_TBS NO /data01/cat_tbs01.dbf
7 50 VPTBS NO /data01/vptbs01.dbfList of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
—- ——– ——————– ———– ——————–
1 29 TEMP 32767 /oracle/oradata/LUDA/datafile/o1_mf_temp_8b3t8vw4_.tmp
通过测试可以发现rman用户的catalog信息导入rman1用户的catalog之后,rman用户的catalog信息就清除掉了;而实际在使用过程中可以使用NO UNREGISTER参数来指定不删除源用户(这里指RMAN用户)的catalog信息。
2.不同数据库之间的用户的catalog迁移
不同用户数据库用户之间的catalog迁移参考测试1中的用户连接
import catalog rman/oracle@luda db_name=luda;
比如是把rman用户下OMR数据库的catalog信息迁移到rman1
命令如下:
rman catalog rman1/oracle@luda 登陆rman
import catalog rman/oracle@omr db_name=omr;