不停机进行Oracle数据库克隆的实验
目标:主库不停机,搭建出一个测试环境,允许少量的数据不同步,不用逻辑导入导出,使用rman实现同机复制数据库-131服务器上将PROD库通过rman-duplicate target database to PRODDUP1的方式进行复制
131服务器是建在VMware上的Linux虚拟机
服务器192.168.182.131
OEL5.8_32
Oracle 11.2.0.1.0 32bit
[oracle@oelr5u8-1 admin]$ uname -a
Linux oelr5u8-1.localdomain 2.6.32-300.10.1.el5uek #1 SMP Wed Feb 22 17:22:40 EST 2012 i686 i686 i386 GNU/Linux
SYS@PROD>select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
过程中会经过几种测试:
1. 尝试不作任何配置,直接执行duplicate target database to PRODDUP1;
RMAN> duplicate target database to PRODDUP1;
Starting Duplicate Db at 05-APR-14
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 04/05/2014 11:10:29
RMAN-06174: not connected to auxiliary database
--DUPLICATE命令作为RMAN中的一个命令,要创建Duplicate数据库,首先就得保证RMAN客户端能够正常连接到目标数据库(PROD)和启动到NOMOUNT状态的辅助实例(即上面报错的“auxiliary database”)
2. 尝试完整的实战-参考三思的教程,感谢!
本地创建Duplicate数据库
复杂度最高,由于本地创建Duplicate数据库,新创建的文件路径不能与目标数据库相同,本地创建需要注意辅助实例初始化参数中DB_NAME与目标数据库不能相同。
核心要求:
保证辅助实例的初始化参数中文件路径的正确有效
执行DUPLICATE命令时,注意与辅助实例初始化参数设置的配合
2.1) 创建辅助实例 auxiliary instance
2.1.1) 创建辅助实例的密钥文件
orapwd file=orapwPRODDUP1 password=oracle
2.1.2) 指定环境变量ORACLE_SID--auxiliary instance
export ORACLE_SID=PRODDUP1
2.1.3) 配置初始化参数文件
由于11g与10g管理目录的区别,在11g库中查询:
audit_file_dest string /u01/app/oracle/admin/PROD/adump
background_dump_dest string /u01/app/oracle/diag/rdbms/prod/PROD/trace
core_dump_dest string /u01/app/oracle/diag/rdbms/prod/PROD/cdump
user_dump_dest string /u01/app/oracle/diag/rdbms/prod/PROD/trace
并且参数文件initPROD.ora中只指定了audit_file_dest,我们这里只手工创建路径adump,其他路径看ORACLE是否能够自动创建
cd $ORACLE_BASE/admin
mkdir -p ./PRODDUP1/adump
下面创建其他数据库文件(控制文件、日志文件、数据文件)的路径:
mkdir -p /u01/app/oracle/oradata/PRODDUP1/disk1
mkdir -p /u01/app/oracle/oradata/PRODDUP1/disk2
mkdir -p /u01/app/oracle/oradata/PRODDUP1/disk3
mkdir -p /u01/app/oracle/oradata/PRODDUP1/disk4
mkdir -p /u01/app/oracle/oradata/PRODDUP1/disk5
下面修改参数文件内容,先进行复制
cd $ORACLE_HOME/dbs
cp initPROD.ora initPRODDUP1.ora
vi initPRODDUP1.ora
PROD.__db_cache_size=230686720
PROD.__java_pool_size=4194304
PROD.__large_pool_size=4194304
PROD.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
PROD.__pga_aggregate_target=314572800
PROD.__sga_target=419430400
PROD.__shared_io_pool_size=0
PROD.__shared_pool_size=163577856
PROD.__streams_pool_size=8388608
*.audit_file_dest='/u01/app/oracle/admin/PROD/adump'
*.audit_trail='db'
*.compatible='11.2.0'
*.control_files='/u01/app/oracle/oradata/PROD/disk1/control01.ctl','/u01/app/oracle/oradata/PROD/disk2/control02.ctl','/u01/app/oracle/oradata/PROD/disk3/control03.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='PROD'
*.db_recovery_file_dest='/home/oracle/flash'
*.db_recovery_file_dest_size=2G
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
*.local_listener='listener2'
*.log_archive_dest_1='location=/home/oracle/arch'
*.memory_target=700M
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=400M
*.undo_management='auto'
*.undo_tablespace='UNDOTBS1'
改为:
PRODDUP1.__db_cache_size=230686720
PRODDUP1.__java_pool_size=4194304
PRODDUP1.__large_pool_size=4194304
PRODDUP1.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
PRODDUP1.__pga_aggregate_target=314572800
PRODDUP1.__sga_target=419430400
PRODDUP1.__shared_io_pool_size=0
PRODDUP1.__shared_pool_size=163577856
PRODDUP1.__streams_pool_size=8388608
*.audit_file_dest='/u01/app/oracle/admin/PRODDUP1/adump'
*.audit_trail='db'
*.compatible='11.2.0'
*.control_files='/u01/app/oracle/oradata/PRODDUP1/disk1/control01.ctl','/u01/app/oracle/oradata/PRODDUP1/disk2/control02.ctl','/u01/app/oracle/oradata/PRODDUP1/disk3/control03.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='PRODDUP1'
*.db_recovery_file_dest='/home/oracle/flash'
*.db_recovery_file_dest_size=2G
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
*.local_listener='listener2'
*.log_archive_dest_1='location=/home/oracle/arch'
*.memory_target=700M
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=400M
*.undo_management='auto'
*.undo_tablespace='UNDOTBS1'
## add for duplicate
DB_FILE_NAME_CONVERT='PROD','PRODDUP1'
LOG_FILE_NAME_CONVERT='PROD','PRODDUP1'