RMAN中建立Catalog 用数据库的例子
RMAN中可以备份metadata到control文件,也可以备份metadata到数据库中,此数据库称为catalog database。
本文参考网上文章,建立一个例子:
使用机器:
机器1:target 机 o_target.loc 192.168.10.111 要备份的数据库。
机器2:catalog 机 o_catalog.loc 192.168.10.112 RMAN catalog metadata 所保存的位置。
由于涉及到两台机器。
分别进行说说明:
在机器1上的/etc/hosts文件:
-----------------------------------------------------
[root@o_target ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.10.111 o_target.loc o_target
192.168.10.112 o_catalog.loc o_catalog
[root@o_target ~]#
-----------------------------------------------------
在机器2上的/etc/hosts文件:
-----------------------------------------------------
[root@o_catalog ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.10.111 o_target.loc o_target
192.168.10.112 o_catalog.loc o_catalog
[root@o_catalog ~]#
-----------------------------------------------------
启动target机的数据库和lisenter:
-----------------------------------------------------
[root@o_target ~]# su - oracle
[oracle@o_target ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Fri Mar 14 14:47:14 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 1023004672 bytes
Fixed Size 2219752 bytes
Variable Size 624951576 bytes
Database Buffers 390070272 bytes
Redo Buffers 5763072 bytes
Database mounted.
Database opened.
SQL>
[root@o_target ~]# su - oracle
[oracle@o_target ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-MAR-2014 14:48:45
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/o_target/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 14-MAR-2014 14:48:45
Uptime 0 days 0 hr. 0 min. 2 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/o_target/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@o_target ~]$
-----------------------------------------------------
然后,在catalog机上,建立连接到target机的本地服务名:
-----------------------------------------------------
[root@o_catalog ~]# xhost +
access control disabled, clients can connect from any host
[root@o_catalog ~]# su - oracle
[oracle@o_catalog ~]$ netca
Oracle Net Services Configuration:
Default local naming configuration complete.
Created net service name: target_orcl
Oracle Net Services configuration successful. The exit code is 0
[oracle@o_catalog ~]$ cd $ORACLE_HOME
[oracle@o_catalog dbhome_1]$ cd ./network/admin
[oracle@o_catalog admin]$ ls
listener14031411AM1252.bak shrept.lst
listener14031411AM1303.bak tnsnames14031411AM1252.bak
listener1403143PM4135.bak tnsnames14031411AM1303.bak
listener.ora tnsnames1403143PM4135.bak
samples tnsnames.ora
[oracle@o_catalog admin]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin
[oracle@o_catalog admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
TARGET_ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = o_target.loc)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
[oracle@o_catalog admin]$
-----------------------------------------------------
再启动catalog机上的DB和listener:
-----------------------------------------------------
[root@o_catalog ~]# su - oracle
[oracle@o_catalog ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Fri Mar 14 16:01:03 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup;
ORACLE instance started.
Total System Global Area 1023004672 bytes
Fixed Size 2219752 bytes
Variable Size 624951576 bytes
Database Buffers 390070272 bytes
Redo Buffers 5763072 bytes
Database mounted.
Database opened.
SQL>
[root@o_catalog ~]# su - oracle
[oracle@o_catalog ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-MAR-2014 16:43:40
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/o_catalog/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=o_catalog.loc)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=o_catalog.loc)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 14-MAR-2014 16:43:40
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/o_catalog/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=o_catalog.loc)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@o_catalog ~]$
[oracle@o_catalog ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-MAR-2014 16:44:44
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=o_catalog.loc)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 14-MAR-2014 16:43:40
Uptime 0 days 0 hr. 1 min. 4 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/o_catalog/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=o_catalog.loc)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@o_catalog ~]$
-----------------------------------------------------
Catalog机上,为rman 用户进行准备:
-----------------------------------------------------
[root@o_catalog ~]# su - oracle
[oracle@o_catalog ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Fri Mar 14 16:09:03 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create tablespace rmancatalog_tb datafile
2 '/u01/app/oracle/oradata/orcl/rman.dbf' size 50M;
Tablespace created.
SQL> create user rman identified by rman default tablespace rmancatalog_tb;
User created.
SQL> grant recovery_catalog_owner to rman;
Grant succeeded.
SQL> alter user rman quota unlimited on rmancatalog_tb;
User altered.
SQL>
SQL> grant dba to rman;
Grant succeeded.
SQL> grant connect,resource to rman;
Grant succeeded.
SQL>
-----------------------------------------------------
在target机器上、为了从catalog机器上可以访问到target机器,进行设置:
------------------------------------------------------
[oracle@o_target ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Fri Mar 14 16:21:10 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create user for_rman identified by for_rman;
User created.
SQL> grant dba to for_rman;
Grant succeeded.
SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@o_target ~]$
[oracle@o_target ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Fri Mar 14 16:23:25 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> grant sysdba to for_rman;
Grant succeeded.
SQL>
------------------------------------------------------
最后,从catalog机器上,执行RMAN:
------------------------------------------------------
[oracle@o_catalog ~]$ rman catalog rman/rman@orcl target for_rman/for_rman@target_orcl
Recovery Manager: Release 11.2.0.1.0 - Production on Fri Mar 14 16:49:37 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1369869147)
connected to recovery catalog database
RMAN>
RMAN> create catalog;
recovery catalog created
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN> list backup;
specification does not match any backup in the repository
RMAN>
------------------------------------------------------