RMAN支持两种类型复制:活动数据库复制和基于备份的复制,主要用来建立测试库。分别进行测试
我们把要复制的数据库称为源数据库(SOURCE DB=orcl),复制后的数据库成为目标数据库(TARGET DB=bdup),不容易搞混。
一、基于备份的测试
测试环境:同一台主机,OS=RHEL 6.4; DB=Oracle11gR2
1.在目标数据库上创建密码文件
[oracle@myrac1 ~]$ cd /s01/app/oracle/product/11.2.0/dbhome_1/dbs/
[oracle@myrac1 dbs]$ pwd
/s01/app/oracle/product/11.2.0/dbhome_1/dbs
[oracle@myrac1 dbs]$ orapwd file='/s01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwhjjdb' password=oracle entries=10
2.在目标端创建相应的目录
[oracle@myrac1 admin]$ pwd
/s01/app/oracle/admin
[oracle@myrac1 admin]$ mkdir hjjdb
[oracle@myrac1 admin]$ cd hjjdb/
[oracle@myrac1 hjjdb]$ mkdir adump dpdump pfile scripts
3.在目标端创建初始化参数文件
[oracle@myrac1 dbs]$ vi inithjjdb.ora
hjjdb.__db_cache_size=146800640
hjjdb.__Java_pool_size=4194304
hjjdb.__large_pool_size=4194304
hjjdb.__oracle_base='/s01/app/oracle'#ORACLE_BASE set from environment
hjjdb.__pga_aggregate_target=104857600
hjjdb.__sga_target=314572800
hjjdb.__shared_io_pool_size=0
hjjdb.__shared_pool_size=150994944
hjjdb.__streams_pool_size=0
*._in_memory_undo=FALSE
*.audit_file_dest='/s01/app/oracle/admin/hjjdb/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='+DATA_DG/hjjdb/control01.ctl','+DG_FRA/hjjdb/control02.ctl'
*.db_block_size=8192
*.db_create_file_dest='+DATA_DG'
*.db_domain=''
*.db_name='hjjdb'
*.db_recovery_file_dest='+DG_FRA'
*.db_recovery_file_dest_size=2147483648
*.diagnostic_dest='/s01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=hjjdbXDB)'
*.open_cursors=300
*.pga_aggregate_target=104857600
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=314572800
*.undo_tablespace='UNDOTBS1'
*.db_file_name_convert=('+DATA_DG/hjj/datafile','+DATA_DG/hjjdb/datafile')
*.log_file_name_convert=('+DG_FRA/hjj/onlinelog','+DG_FRA/hjjdb/onlinelog')
4.启动目标数据库到NOMOUNT状态
[oracle@myrac1 dbs]$ export ORACLE_SID=hjjdb
[oracle@myrac1 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 5 00:13:04 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup pfile='/s01/app/oracle/product/11.2.0/dbhome_1/dbs/inithjjdb.ora' nomount
ORACLE instance started.
Total System Global Area 313860096 bytes
Fixed Size 1336232 bytes
Variable Size 159386712 bytes
Database Buffers 146800640 bytes
Redo Buffers 6336512 bytes
5.在目标端配置listener.ora和tnsnames.ora
[grid@myrac1 admin]$ cat listener.ora
# listener.ora Network Configuration File: /g01/app/grid/product/11.2.0/grid/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = myrac1)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /g01/app/grid
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
这部分需要自己添加,listener.ora文件中没有的。
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
#BEQUEATH CONFIG
(GLOBAL_DBNAME=hjjdb)
(SID_NAME=hjjdb)
(ORACLE_HOME=/s01/app/oracle/product/11.2.0/dbhome_1)
#PRESPAWN CONFIG
(PRESPAWN_MAX=20)
(PRESPAWN_LIST=
(PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))
)
)
)
[oracle@myrac1 admin]$ vi tnsnames.ora
# tnsnames.ora Network Configuration File: /s01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.