参考
实验平台: redhat + oracle 10g
target库的相关信息:
ORACLE_BASE: /u01/app/oracle
ORACLE_HOME: /u01/app/oracle/product/10.2.0/db_1
target ORACLE_SID:ora10g
auxiliary库的相关信息:
ORACLE_BASE: /u01/app/oracle
ORACLE_HOME: /u01/app/oracle/product/10.2.0/db_1
auxiliary ORACLE_SID:ora10g2
目的:使用 DUPLICATE database方法,根据target数据库创建auxiliary数据库
步骤如下:
(1)构建辅助数据库目录结构
(2)修改init.ora 初始话文件
(3)创建辅助实例口令文件
(4)RMAN 备份源库
(5)配置监听
(6)启动辅助库至nomount 状态
(7)RMAN duplicate复制实例
(8)创建spfile
一.构建辅助数据库目录结构
二.修改init.ora初始化文件
连接target数据库,根据spfile创建pfile文件
SQL> create pfile from spfile;
进入$ORACLE_HOME/dbs目录,将init 文件copy并重命名为initora10g2.ora.这个命名格式必须和实例名相同,不然数据库不能识别。
修改initora10g2.ora为
ora10g2.__db_cache_size=159383552
ora10g2.__java_pool_size=4194304
ora10g2.__large_pool_size=4194304
ora10g2.__shared_pool_size=88080384
ora10g2.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/ora10g2/adump'
*.audit_sys_operations=FALSE
*.audit_trail='NONE'
*.background_dump_dest='/u01/app/oracle/admin/ora10g2/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/app/oracle/oradata/ora10g2/control01.ctl','/u01/app/oracle/oradata/ora10g2/control02.ctl','/u01/app/oracle/oradata/ora10g2/control03.ctl'#Restore Controlfile
*.core_dump_dest='/u01/app/oracle/admin/ora10g2/cdump'
*.db_16k_cache_size=0
*.db_block_size=8192
*.db_create_online_log_dest_1=''
*.db_create_online_log_dest_2=''
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='ora10g2'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ora10gXDB)'
*.job_queue_processes=10
*.local_listener=''
*.open_cursors=300
*.pga_aggregate_target=87031808
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.resource_limit=TRUE
ora10g.resource_manager_plan=''
*.service_names='ora10g2'
*.sga_target=264241152
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/ora10g2/udump'
db_file_name_convert = ('/u01/app/oracle/oradata/ora10g','/u01/app/oracle/oradata/ora10g2')
log_file_name_convert = ('/u01/app/oracle/oradata/ora10g','/u01/app/oracle/oradata/ora10g2')
三.创建DAVE实例的口令文件
orapwd FILE=/u01/app/oracle/oradata/product/10.2.0/db_1/dbs/orapwdORA10G2 PASSWORD=oracle ENTRIES=30
五.添加,配置监听
六.启动辅助库到nomount状态
#export ORACLE_SID=ora10g2
#sqlplus / as sysdba
SQL> startup nomount pfile=$ORACLE_HOME/dbs/initora10g2.ora
七.RMAN 连接到目标实例和辅助实例,备份数据库,拷贝备份文件到auxiliary数据库,运行duplicate 命令复制数据库
1、备份target数据库
run {
allocate channel ch1 device type disk maxpiecesize=10g;
sql 'alter system archive log current';
change archivelog all crosscheck;
backup full database tag=ora10gdbfullbk
format '/u01/app/oracle/admin/ora10g/arch/%d_db_%t_%s_%p'
plus archivelog format '/u01/app/oracle/admin/ora10g/arch/%d_arch_%t_%s_%p' delete all input;
backup current controlfile
format '/u01/app/oracle/admin/ora10g/arch/%d_ctlfile_%t_%s_%p';
release channel ch1;
}
RUN {
allocate channel c1 type disk;
allocate channel c2 type disk;
BACKUP FORMAT '/u01/backup/orcl_%U_%T' skip inaccessible filesperset 5 DATABASE TAG orcl_hot_db_bk;
sql 'alter system archive log current';
BACKUP FORMAT '/u01/backup/arch_%U_%T' skip inaccessible filesperset 5 ARCHIVELOG ALL DELETE INPUT;
backup current controlfile tag='bak_ctlfile' format='/u01/backup/ctl_file_%U_%T';
backup spfile tag='spfile' format='/u01/backup/ORCL_spfile_%U_%T';
release channel c2;
release channel c1;
}
2、使用scp命令将target数据库下的所有文件拷贝到auxiliary数据库中。
scp -r oracle@192.168.2.101:/u01/backup /u01/backup
3、使用duplicate 命令复制数据库
RMAN>duplicate target database to ora10g2 nofilenamecheck;
八.修改辅助库的pfile,在创建spfile
8.1删除下面2句:
db_file_name_convert = ('/u01/app/oracle/oradata/ora10g','/u01/app/oracle/oradata/ora10g2')
log_file_name_convert = ('/u01/app/oracle/oradata/ora10g','/u01/app/oracle/oradata/ora10g2')
8.2 创建spfile
SQL> create spfile from pfile='/u01/app/oracle/product/10.2.0/db_1/dbs/initora10g.ora';