MAN catalog恢复目录:
当没有恢复目录的时候,RMAN相关的备份信息,比如归档路径、备份集路径等均存在目标数据库的控制文件,但是控制文件并不能无限增长,而且控制文件也不仅仅是用来存储与备份相关的信息,因此RMAN也有一个专门存放备份信息的地方。当待备份的数据库注册到恢复目录之后,RMAN相关的信息除了保存在控制文件中外(只保存一部分),更加详细的信息就被存在恢复目录中。
注意:不要将恢复目录数据库放到目标数据库中。
1.1.创建恢复目录所有者默认表空间
SYS@ORA11GR2>create tablespacets_catalogdatafile '/u01/app/oracle/oradata/ORA11GR2/ts_catalog.dbf' size 15m;
Tablespace created.
1.2.创建恢复目录所有者
——创建用户rcowner并授予RECOVERY_CATALOG_OWNER角色
SYS@ORA11GR2>create userrcowner identified
by oracle temporary
tablespace temp default tablespace ts_catalog quota unlimited on ts_catalog;
User created.
SYS@ORA11GR2>grantrecovery_catalog_owner to rcowner;
Grant succeeded.
——回到操作系统创建本库自己的tnsnames.ora
[oracle@wang ~]$ cd
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/
[oracle@wang admin]$ ls
listener.orasamplesshrept.lst
[oracle@wang admin]$ vi tnsnames.ora
ora=
(description=
(address=(protocol=tcp)(host=wang)(port=1521))
(connect_data=
(service_name=ORA11GR2)))
"tnsnames.ora" [New] 5L, 118C
written
[oracle@wang admin]$
——测试tns:
[oracle@wang admin]$tnsping ora
TNS Ping Utility for Linux: Version
11.2.0.4.0 - Production on 28-SEP-2016 23:35:29
Copyright (c) 1997, 2013, Oracle.All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (description=
(address=(protocol=tcp)(host=wang)(port=1521)) (connect_data=
(service_name=ORA11GR2)))
OK (50 msec)
[oracle@wang admin]$
1.3.创建恢复目录
[oracle@wang admin]$rmancatalog rcowner/oracle@ora
(登录恢复目录数据库)
Recovery Manager: Release 11.2.0.4.0 -
Production on Wed Sep 28 23:38:37 2016
Copyright (c) 1982, 2011, Oracle and/or its
affiliates.All rights reserved.
connected
to recovery catalog database
——创建恢复目录
RMAN>create catalog;
recovery catalog created
注create catalog的动作是在rcowner用户下创建了恢复目录相关的表,表的默认表空间使用的就是用户的默认表空间,如果,相关表指定其他表空间,那么在执行创建的时候加上指定表空间名称create catalog tablespacets_name;
1.4.注册目标数据库
1)在恢复目录中注册目标数据库
[oracle@wang ~]$rman target / catalog rcowner/oracle@ora
(此步骤我是注册本地的数据库到恢复目录中去)
【当要注册目标数据库到远程恢复目录中去时,1.要配置tns连接网络;2.执行rmantarget
sys/oracle@ora11gr2 catalog
rcowner/oracle@orcl,使用RMAN连接到目标数据库(要注册的数据库)和恢复目录数据库以及注册到远程恢复目录时,必须要加上账号密码,且要配置好本机及远程的tns及别名】
Recovery Manager: Release 11.2.0.4.0 -
Production on Thu Sep 29 06:47:48 2016
Copyright (c) 1982, 2011, Oracle and/or its
affiliates.All rights reserved.
connected to target database: ORA11GR2
(DBID=237843809)
connected to recovery catalog database
RMAN>register database;
database
registered in recovery catalog
starting
full resync of recovery catalog
full
resync complete
2)查看已注册的目标库
[oracle@wang ~]$sqlplus
rcowner/oracle@ora
SQL*Plus: Release 11.2.0.4.0 Production on
Thu Sep 29 06:56:22 2016
Copyright (c) 1982, 2013, Oracle.All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition
Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining
and Real Application Testing options
RCOWNER@ora>select * fromrc_database;
DB_KEYDBINC_KEYDBID NAMERESETLOGS_CHANGE# RESETLOGS_TIME
---------- ---------- ---------- --------
----------------- -------------------
12237843809 ORA11GR21256742 2016-09-23 15:29:09
3)从恢复目录中注销目标数据库
[oracle@wang ~]$rman target /catalog rcowner/oracle@ora
Recovery Manager: Release 11.2.0.4.0 -
Production on Thu Sep 29 06:59:32 2016
Copyright (c) 1982, 2011, Oracle and/or its
affiliates.All rights reserved.
connected to target database: ORA11GR2
(DBID=237843809)
connected to recovery catalog database
RMAN>unregister database;
database name is "ORA11GR2" and
DBID is 237843809
Do you really want to unregister the
database (enter YES or NO)?yes
database unregistered from the recovery
catalog
?——再次查看已注册的目标数据库
[oracle@wang
~]$sqlplus rcowner/oracle@ora
SQL*Plus: Release 11.2.0.4.0 Production on
Thu Sep 29 07:01:40 2016
Copyright (c) 1982, 2013, Oracle.All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition
Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining
and Real Application Testing options
RCOWNER@ora>select * fromrc_database;
no rows selected(没有已注册的数据库信息)
1.5.手动重新同步恢复目录
1)先要将目标数据库与恢复目录数据库连接起来
[oracle@wang ~]$rmantarget /catalog rcowner/oracle@ora
Recovery Manager: Release 11.2.0.4.0 -
Production on Thu Sep 29 07:11:19 2016
Copyright (c) 1982, 2011, Oracle and/or its
affiliates.All rights reserved.
connected to target database: ORA11GR2
(DBID=237843809)
connected to recovery catalog database
RMAN>register database;(注册数据库)
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN>
——查看:
[oracle@wang
~]$ sqlplus rcowner/oracle@ora
SQL*Plus: Release 11.2.0.4.0 Production on Thu
Sep 29 07:16:50 2016
Copyright (c) 1982, 2013, Oracle.All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition
Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining
and Real Application Testing options
RCOWNER@ora>select * fromrc_database;
DB_KEYDBINC_KEYDBID NAMERESETLOGS_CHANGE# RESETLOGS_TIME
---------- ---------- ---------- --------
----------------- -------------------
272273237843809 ORA11GR21256742 2016-09-23 15:29:09
2)手动重新同步恢复目录:
RMAN>resync catalog;
starting full resync of recovery catalog
full resync complete