一、RMAN duplicate技术原理
目标数据库: 需要复制的数据库
辅助数据库:新的数据库
辅助数据库可以与目标数据库同一台主机或不同主机,物理结构(数据文件位置,在线日志文件位置等)可以相同也可以不同
首先打开辅助数据库实例之后,辅助实例利用目标数据库的备份自动做以下一系列操作:还原并不完全恢复最后直接打开数据库(可以跑过离线表空间或只读表空间)并生成新的DBID标识符。
如果你有过数据库异机恢复的经历就会知道以上操作需要手工繁琐的操作,而RMAN duplicate只需要稍做准备就可以自动完成大部分操作了,很轻松。
二、RMAN duplicate应用场景:
当数据库有打补丁或升级或测试的需求时,我们通常不会直接在生产库上做,此时就需要有一个新数据库的环境。而RMAN duplicate技术就能快速地复制出一个新的数据库(这个新数据库将拥有属于自己的新DBID),在有恢复目录(recovery catalog)的情况下也不会与目标数据库有冲突.
RMANfduplicate都可以完成数据库复制和DATA GUARD搭建,但二者还是有差别的:duplicate技术相当于便捷式的数据库克隆,由于RMAN不会备份redo在线日志,所以duplicate只能利用数据库的备份和归档日志做不完全恢复;如果是DATA GUARD,主备库是通过源源不断地应用日志来维系数据同步的,在主库发生物理故障时可以切换备库为主库。略带补充一下,11G的DATA GUARD相比10G的DATA GUARD在功能上已经有非常大程度的提高,如Snapshot standby,在只读模式下能够应用归档日志等等。由于这部分内容超出本节主题,不再多说。以下为实验过程,实现了同一台主机上数据库的复制.
三、RMAN duplicate注意点
DB_NAME:同主机同ORACLE_HOME场景下,数据库名称必须与目标数据库不同
控制文件: 参数文件里通过control_files控制
在线日志文件: 使用参数log_file_name_convert进行转换,代替手工SET NEWNAME和SWITCH
数据文件和临时数据文件: 使用参数log_file_name_convert进行转换,代替手工SET NEWNAME和SWITCH
四、实验过程
目标数据库:
SQL> select dbid,name,open_mode from v$database;
DBID NAME OPEN_MODE
---------- -------------- -------------
4160719624 ORA10G
新数据库名称: dup10g数据库
1、创建目录
mkdir -p /u01/app/oracle/oradata/dup10gmkdir -p /u01/app/oracle/admin/dup10g/udumpmkdir -p /u01/app/oracle/admin/dup10g/cdumpmkdir -p /u01/app/oracle/admin/dup10g/bdumpmkdir -p /u01/app/oracle/admin/dup10g/adump----------------------------------------------------
2、准备参数文件和密码文件
[oracle@tivoli02 ~]$ cat /u01/app/oracle/product/10.2.0/db_1/dbs/initdup10g.ora
*.__db_cache_size=167772160
*.audit_file_dest='/u01/app/oracle/admin/dup10g/adump'
*.background_dump_dest='/u01/app/oracle/admin/dup10g/bdump'
*.compatible='10.2.0.5.0'
*.core_dump_dest='/u01/app/oracle/admin/dup10g/cdump'
*.db_block_size=8192
*.db_file_multiblock_read_count=16
*.db_name='dup10g'
*.job_queue_processes=10
*.open_cursors=300
*.pga_aggregate_target=158334976
*.remote_login_passwordfile='EXCLUSIVE'
*.sql_trace=FALSE
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/dup10g/udump'
*.CONTROL_FILES='/u01/app/oracle/oradata/dup10g/dup10g.ctl'
*.DB_FILE_NAME_CONVERT='/backup/copy/','/u01/app/oracle/oradata/dup10g/'
*.LOG_FILE_NAME_CONVERT='/backup/copy/','/u01/app/oracle/oradata/dup10g/'
[oracle@tivoli02 ~]$ cd /u01/app/oracle/product/10.2.0/db_1/dbs/
[oracle@tivoli02 dbs]$ ls -lrt orapw*
-rw-r----- 1 oracle oinstall 1536 Jun 3 15:58 orapwora10g
-rw-r----- 1 oracle oinstall 1536 Jul 7 09:14 orapwstb
[oracle@tivoli02 dbs]$ cp -rp orapwora10g orapwdup10g
3、启动数据库实例
[oracle@tivoli02 ~]$ export ORACLE_SID=dup10g
[oracle@tivoli02 ~]$ sqlplus / as sysdbaSQL*Plus: Release 10.2.0.5.0 - Production on Thu Sep 25 15:28:44 2014
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup nomount;
ORA-32004: obsolete and/or deprecated parameter(s) specified
ORACLE instance started.Total System Global Area 260046848 bytes
Fixed Size 2095472 bytes
Variable Size 113247888 bytes
Database Buffers 134217728 bytes
Redo Buffers 10485760 bytes
4、主库 备份数据库
export ORACLE_SID=ora10g
rman target /RMAN> run{
allocate channel ch1 type disk;
allocate channel ch2 type disk;
allocate channel ch3 type disk;
allocate channel ch4 type disk;
backup as BACKUPSET full tag 'db_full' format '/backup/dup_db_%d_%T_%s_%U.bak' database include current controlfile;
sql 'alter system archive log current';
backup as BACKUPSET archivelog all format '/backup/dup_%d_arc_%T_s%s_p%p_%U';
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}
日志输出:
using target database control file instead of recovery catalog
allocated channel: ch1
channel ch1: sid=23 devtype=DISK
allocated channel: ch2
channel ch2: sid=16 devtype=DISK
allocated channel: ch3
channel ch3: sid=15 devtype=DISK
allocated channel: ch4
channel ch4: sid=18 devtype=DISK
Starting backup at 25-SEP-14
channel ch1: starting full datafile backupset
channel ch1: specifying datafile(s) in backupset
input datafile fno=00002 name=/backup/copy/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-UNDOTBS1_FNO-2_2gpbolmn
channel ch1: starting piece 1 at 25-SEP-14
channel ch2: starting full datafile backupset
channel ch2: specifying datafile(s) in backupset
input datafile fno=00001 name=/backup/copy/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-SYSTEM_FNO-1_2hpbolmn
input datafile fno=00008 name=/backup/copy/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSD_FNO-8_2mpbolnh
channel ch2: starting piece 1 at 25-SEP-14
channel ch3: starting full datafile backupset
channel ch3: specifying datafile(s) in backupset
input datafile fno=00003 name=/backup/copy/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-SYSAUX_FNO-3_2ipbolmn
input datafile fno=00007 name=/backup/copy/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSC_FNO-7_2lpbolnh
channel ch3: starting piece 1 at 25-SEP-14
channel ch4: starting full datafile backupset
channel ch4: specifying datafile(s) in backupset
input datafile fno=00005 name=/backup/copy/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSA_FNO-5_2jpbolmn
input datafile fno=00006 name=/backup/copy/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSB_FNO-6_2kpbolmo
channel ch4: starting piece 1 at 25-SEP-14
channel ch4: finished piece 1 at 25-SEP-14
piece handle=/backup/dup_db_ORA10G_20140925_111_3fpjd7me_1_1.bak tag=DB_FULL comment=NONE
channel ch4: backup set complete, elapsed time: 00:00:01
channel ch4: starting full datafile backupset
channel ch4: specifying datafile(s) in backupset
including current control file in backupset
channel ch4: starting piece 1 at 25-SEP-14
channel ch4: finished piece 1 at 25-SEP-14
piece handle=/backup/dup_db_ORA10G_20140925_112_3gpjd7mg_1_1.bak tag=DB_FULL comment=NONE
channel ch4: backup set complete, elapsed time: 00:00:02
channel ch1: finished piece 1 at 25-SEP-14
piece handle=/backup/dup_db_ORA10G_20140925_108_3cpjd7me_1_1.bak tag=DB_FULL comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:11
channel ch3: finished piece 1 at 25-SEP-14
piece handle=/backup/dup_db_ORA10G_20140925_110_3epjd7me_1_1.bak tag=DB_FULL comment=NONE
channel ch3: backup set complete, elapsed time: 00:00:11
channel ch2: finished piece 1 at 25-SEP-14
piece handle=/backup/dup_db_ORA10G_20140925_109_3dpjd7me_1_1.bak tag=DB_FULL comment=NONE
channel ch2: backup set complete, elapsed time: 00:00:12
Finished backup at 25-SEP-14
Starting Control File and SPFILE Autobackup at 25-SEP-14
piece handle=/backup/c_c-4160719624-20140925-00 comment=NONE
Finished Control File and SPFILE Autobackup at 25-SEP-14
sql statement: alter system archive log current
Starting backup at 25-SEP-14
current log archived
channel ch1: starting archive log backupset
channel ch1: specifying archive log(s) in backup set
input archive log thread=1 sequence=6 recid=249 stamp=858639619
input archive log thread=1 sequence=7 recid=250 stamp=858751218
input archive log thread=1 sequence=8 recid=251 stamp=858826829
input archive log thread=1 sequence=9 recid=252 stamp=858985649
input archive log thread=1 sequence=10 recid=253 stamp=859107615
channel ch1: starting piece 1 at 25-SEP-14
channel ch2: starting archive log backupset
channel ch2: specifying archive log(s) in backup set
input archive log thread=1 sequence=1 recid=244 stamp=858000668
input archive log thread=1 sequence=2 recid=245 stamp=858067282
input archive log thread=1 sequence=3 recid=246 stamp=858182417
input archive log thread=1 sequence=4 recid=247 stamp=858311229
input archive log thread=1 sequence=5 recid=248 stamp=858481962
channel ch2: starting piece 1 at 25-SEP-14
channel ch3: starting archive log backupset
channel ch3: specifying archive log(s) in backup set
input archive log thread=1 sequence=1 recid=231 stamp=852074379
input archive log thread=1 sequence=2 recid=232 stamp=852074380
input archive log thread=1 sequence=3 recid=243 stamp=857999925
input archive log thread=1 sequence=4 recid=241 stamp=857999924
input archive log thread=1 sequence=5 recid=242 stamp=857999925
channel ch3: starting piece 1 at 25-SEP-14
channel ch4: starting archive log backupset
channel ch4: specifying archive log(s) in backup set
input archive log thread=1 sequence=694 recid=222 stamp=851203688
input archive log thread=1 sequence=695 recid=223 stamp=851203689
input archive log thread=1 sequence=696 recid=224 stamp=851203689
input archive log thread=1 sequence=697 recid=225 stamp=851292630
input archive log thread=1 sequence=698 recid=229 stamp=852072759
input archive log thread=1 sequence=699 recid=230 stamp=852072759
channel ch4: starting piece 1 at 25-SEP-14
channel ch1: finished piece 1 at 25-SEP-14
piece handle=/backup/dup_ORA10G_arc_20140925_s114_p1_3ipjd7mt_1_1 tag=TAG20140925T153348 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:07
channel ch2: finished piece 1 at 25-SEP-14
piece handle=/backup/dup_ORA10G_arc_20140925_s115_p1_3jpjd7mt_1_1 tag=TAG20140925T153348 comment=NONE
channel ch2: backup set complete, elapsed time: 00:00:07
channel ch3: finished piece 1 at 25-SEP-14
piece handle=/backup/dup_ORA10G_arc_20140925_s116_p1_3kpjd7mt_1_1 tag=TAG20140925T153348 comment=NONE
channel ch3: backup set complete, elapsed time: 00:00:07
channel ch4: finished piece 1 at 25-SEP-14
piece handle=/backup/dup_ORA10G_arc_20140925_s117_p1_3lpjd7mt_1_1 tag=TAG20140925T153348 comment=NONE
channel ch4: backup set complete, elapsed time: 00:00:07
channel ch1: starting archive log backupset
channel ch1: specifying archive log(s) in backup set
input archive log thread=1 sequence=11 recid=254 stamp=859217551
input archive log thread=1 sequence=12 recid=255 stamp=859217552
input archive log thread=1 sequence=13 recid=256 stamp=859217628
input archive log thread=1 sequence=14 recid=257 stamp=859217628
channel ch1: starting piece 1 at 25-SEP-14
channel ch1: finished piece 1 at 25-SEP-14
piece handle=/backup/dup_ORA10G_arc_20140925_s118_p1_3mpjd7n4_1_1 tag=TAG20140925T153348 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:01
Finished backup at 25-SEP-14
Starting Control File and SPFILE Autobackup at 25-SEP-14
piece handle=/backup/c_c-4160719624-20140925-01 comment=NONE
Finished Control File and SPFILE Autobackup at 25-SEP-14
released channel: ch1
released channel: ch2
released channel: ch3
released channel: ch4
5、复制数据库
[oracle@tivoli02 ~]$ rman TARGET / AUXILIARY SYS/oracle@dup10g
Recovery Manager: Release 10.2.0.5.0 - Production on Thu Sep 25 16:28:20 2014
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: ORA10G (DBID=4160719624)
connected to auxiliary database: DUP10G (not mounted)RMAN> RUN {
DUPLICATE TARGET DATABASE to dup10g;
}
2> 3>
日志输出:
Starting Duplicate Db at 25-SEP-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=31 devtype=DISK
contents of Memory Script:
{
set until scn 13007624;
set newname for datafile 1 to
"/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-SYSTEM_FNO-1_2hpbolmn";
set newname for datafile 2 to
"/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-UNDOTBS1_FNO-2_2gpbolmn";
set newname for datafile 3 to
"/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-SYSAUX_FNO-3_2ipbolmn";
set newname for datafile 5 to
"/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSA_FNO-5_2jpbolmn";
set newname for datafile 6 to
"/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSB_FNO-6_2kpbolmo";
set newname for datafile 7 to
"/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSC_FNO-7_2lpbolnh";
set newname for datafile 8 to
"/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSD_FNO-8_2mpbolnh";
restore
check readonly
clone database
;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 25-SEP-14
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00005 to /u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSA_FNO-5_2jpbolmn
restoring datafile 00006 to /u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSB_FNO-6_2kpbolmo
channel ORA_AUX_DISK_1: reading from backup piece /backup/dup_db_ORA10G_20140925_111_3fpjd7me_1_1.bak
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/backup/dup_db_ORA10G_20140925_111_3fpjd7me_1_1.bak tag=DB_FULL
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-UNDOTBS1_FNO-2_2gpbolmn
channel ORA_AUX_DISK_1: reading from backup piece /backup/dup_db_ORA10G_20140925_108_3cpjd7me_1_1.bak
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/backup/dup_db_ORA10G_20140925_108_3cpjd7me_1_1.bak tag=DB_FULL
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:36
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00003 to /u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-SYSAUX_FNO-3_2ipbolmn
restoring datafile 00007 to /u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSC_FNO-7_2lpbolnh
channel ORA_AUX_DISK_1: reading from backup piece /backup/dup_db_ORA10G_20140925_110_3epjd7me_1_1.bak
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/backup/dup_db_ORA10G_20140925_110_3epjd7me_1_1.bak tag=DB_FULL
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-SYSTEM_FNO-1_2hpbolmn
restoring datafile 00008 to /u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSD_FNO-8_2mpbolnh
channel ORA_AUX_DISK_1: reading from backup piece /backup/dup_db_ORA10G_20140925_109_3dpjd7me_1_1.bak
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/backup/dup_db_ORA10G_20140925_109_3dpjd7me_1_1.bak tag=DB_FULL
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 25-SEP-14
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DUP10G" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 584
LOGFILE
GROUP 7 ( '/u01/app/oracle/oradata/dup10g/redo07.log' ) SIZE 50 M REUSE,
GROUP 8 ( '/u01/app/oracle/oradata/dup10g/redo08.log' ) SIZE 50 M REUSE,
GROUP 9 ( '/u01/app/oracle/oradata/dup10g/redo09.log' ) SIZE 50 M REUSE
DATAFILE
'/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-SYSTEM_FNO-1_2hpbolmn'
CHARACTER SET N8PC865
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=859221513 filename=/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-UNDOTBS1_FNO-2_2gpbolmn
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=859221513 filename=/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-SYSAUX_FNO-3_2ipbolmn
datafile 5 switched to datafile copy
input datafile copy recid=3 stamp=859221513 filename=/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSA_FNO-5_2jpbolmn
datafile 6 switched to datafile copy
input datafile copy recid=4 stamp=859221513 filename=/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSB_FNO-6_2kpbolmo
datafile 7 switched to datafile copy
input datafile copy recid=5 stamp=859221513 filename=/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSC_FNO-7_2lpbolnh
datafile 8 switched to datafile copy
input datafile copy recid=6 stamp=859221513 filename=/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSD_FNO-8_2mpbolnh
contents of Memory Script:
{
set until scn 13007624;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 25-SEP-14
using channel ORA_AUX_DISK_1
starting media recovery
archive log thread 1 sequence 13 is already on disk as file /u01/app/oracle/product/10.2.0/db_1/dbs/arch1_13_857999924.dbf
archive log thread 1 sequence 14 is already on disk as file /u01/app/oracle/product/10.2.0/db_1/dbs/arch1_14_857999924.dbf
archive log filename=/u01/app/oracle/product/10.2.0/db_1/dbs/arch1_13_857999924.dbf thread=1 sequence=13
archive log filename=/u01/app/oracle/product/10.2.0/db_1/dbs/arch1_14_857999924.dbf thread=1 sequence=14
media recovery complete, elapsed time: 00:00:03
Finished recover at 25-SEP-14
contents of Memory Script:
{
shutdown clone;
startup clone nomount ;
}
executing Memory Script
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 260046848 bytes
Fixed Size 2095472 bytes
Variable Size 113247888 bytes
Database Buffers 134217728 bytes
Redo Buffers 10485760 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DUP10G" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 584
LOGFILE
GROUP 7 ( '/u01/app/oracle/oradata/dup10g/redo07.log' ) SIZE 50 M REUSE,
GROUP 8 ( '/u01/app/oracle/oradata/dup10g/redo08.log' ) SIZE 50 M REUSE,
GROUP 9 ( '/u01/app/oracle/oradata/dup10g/redo09.log' ) SIZE 50 M REUSE
DATAFILE
'/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-SYSTEM_FNO-1_2hpbolmn'
CHARACTER SET N8PC865
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/dup10g//temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-UNDOTBS1_FNO-2_2gpbolmn";
catalog clone datafilecopy "/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-SYSAUX_FNO-3_2ipbolmn";
catalog clone datafilecopy "/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSA_FNO-5_2jpbolmn";
catalog clone datafilecopy "/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSB_FNO-6_2kpbolmo";
catalog clone datafilecopy "/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSC_FNO-7_2lpbolnh";
catalog clone datafilecopy "/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSD_FNO-8_2mpbolnh";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to /u01/app/oracle/oradata/dup10g//temp01.dbf in control file
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-UNDOTBS1_FNO-2_2gpbolmn recid=1 stamp=859222132
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-SYSAUX_FNO-3_2ipbolmn recid=2 stamp=859222132
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSA_FNO-5_2jpbolmn recid=3 stamp=859222132
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSB_FNO-6_2kpbolmo recid=4 stamp=859222132
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSC_FNO-7_2lpbolnh recid=5 stamp=859222133
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSD_FNO-8_2mpbolnh recid=6 stamp=859222133
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=859222132 filename=/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-UNDOTBS1_FNO-2_2gpbolmn
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=859222132 filename=/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-SYSAUX_FNO-3_2ipbolmn
datafile 5 switched to datafile copy
input datafile copy recid=3 stamp=859222132 filename=/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSA_FNO-5_2jpbolmn
datafile 6 switched to datafile copy
input datafile copy recid=4 stamp=859222132 filename=/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSB_FNO-6_2kpbolmo
datafile 7 switched to datafile copy
input datafile copy recid=5 stamp=859222133 filename=/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSC_FNO-7_2lpbolnh
datafile 8 switched to datafile copy
input datafile copy recid=6 stamp=859222133 filename=/u01/app/oracle/oradata/dup10g/copy_ORA10G_data_D-ORA10G_I-4160719624_TS-TSD_FNO-8_2mpbolnh
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 25-SEP-14
6、检验数据库
到此,最简单的数据库复制已经完成,如果有更复杂的应用场景大家可以动手做一下,如异机但目录一致,异常且目录不一致等
SQL> select dbid,name,open_mode from v$database;
DBID NAME OPEN_MODE
---------- ---------- ----------------
3611020979 DUP10G READ WRITE