OracleDUPLICATE复制数据库一、DUPLICATE复制数据库1.使用duplicate命令可以在不影响目标数据库(Target/PrimaryDatabase)的情况下,依靠目标数据库的备份集创建一个Duplicate数据库(数据库副本)。在创建时既...Syntax
一、DUPLICATE复制数据库
1.使用duplicate命令可以在不影响目标数据库(Target/Primary Database)的情况下,依靠目标数
据库的备份集创建一个Duplicate数据库(数据库副本)。
在创建时既可以选择完整复制目标数据库,也可以仅包含目标数据库中的部分表空间,目标数据库
和Duplicate数据库甚至可以在同一台机器上。
2.Duplicate数据库是目标数据库在某个时间点的一个副本。可以把它当作很正式的测试数据库。
比如:
a.测试备份和恢复的过程:从host1复制一份生产数据库到host2,然后使用host2上的副本数据库
实现恢复,修复操作,Target Db不受影响。
b.导出数据:在目标数据库上的被有意无意的删除表,可以先使用备份创建一个删除表之前的数据
库副本,然后将被删除的报导回目标数据库。 www.2cto.com
3. duplicate target database to newdbname;
4.除了创建副本数据库之外,duplicate命令还能用来创建物理standby数据库;而不是创建Data
Guard环境,而是创建Data Guard的物理standby数据库而已,
duplicate数据库和物理standby数据库还是有区别的
a.物理standby是primary数据库的一份完整复制,还可以根据primary的archived logs定期或不定
期地更新它,如果primary崩溃,DBA还可以将其切换为primary继续使用。
b.Duplicate并不是为了容灾和故障切换而设计的。
二、创建duplicate数据库的过程
1.从复制数据库文件至创建duplicate数据库,都是在辅助实例所在的服务器上完成的,因此务必保
证辅助数据库实例所在的服务器能够访问到所需的备份文件和归档文件。
如果辅助实例与目标数据库不在同一台服务器上,DBA必须手工复制创建duplicate数据库所需的备份
和归档文件,到辅助实例所在的服务器的适当目录下(默认情况下备份集在辅助实例所在服务器的路径,
应该与源数据库备份集的路径相同)。如果备份集保存在磁带上,那么必须在辅助实例所在服务器上
配置磁带介质管理器,以便能访问到磁带上保存的备份集。
2.一般建议保持目标数据库和duplicate数据库两端路径相同,这样配置过程会更加简单,如果路
径无法保持一致,就必须通过一些设置来确保辅助实例能够正常读取,创建duplicate数据库所需
的文件,并将其创建至正确的路径下。复制数据库的命令很简单:RMAN>duplicate target database to orcldup;执行这条命令RMAN会自动执行以下步骤:
a.为duplicate数据库创建控制文件
b.restore命令修复数据文件到duplicate数据库,recover命令对duplicate数据库进行不完全恢复;
大多数情况下,创建duplicate数据库期间,RMAN都需要进行不完全恢复,因为目标数据库的Online
Redologs
并不能实时备份、传输并应用到duplicate数据库,RMAN最多也就能将目标数据库最近一次备份的数
据恢复到duplicate数据库。 www.2cto.com
c.重启辅助实例
d.以OPEN RESETLOGS方式打开duplicate数据库,重建Online Redologs(提示:Duplicate.. for
standby方式不会打开数据库)。
e.为duplicate数据库产生一个新的唯一的DBID(Duplicate ...for standby方式除外,它不会创建
新的唯一的DBID)。
3.如果duplicate数据库与目标数据库在同一台服务器上,那么必须重新设置辅助实例的一些关键初
始化参数,如DB_NAME,CONTROL_FILES,*_PATH,*_DEST等,为不同的实例初始化参数指定不同的参数
值,同时Duplicate
数据库的数据文件。redologs等文件路径也需要重新定义,不然在创建过程中会出现错误,甚至影响
正式的产品数据库。
duplicate数据库一旦创建成功,就与原目标数据库没有物理联系;duplicate也拥有一个全新唯一
的DBID;duplicate命令不支持跨平台复制数据库。使用duplicate命令创建数据库,只是目标数据
库某个时间点的复制,不可能将duplicate数据库与目标数据库完全保持一致,除非创建的是物理
standby数据库。
4.duplicate创建流程
a.相同路劲结构的复制
(1)创建辅助实例
(2)RMAN连接并云顶DUPLICATE命令,结束。
如果没有配置自动分配通道的话,至少手工指定1条通道。
对于异机恢复,如果源数据库和目标数据苦的数据文件路径相同,必须指定NOFILENAMECHECK来避
免
Oracle的自动识别。
DUPLICATE TARGET DATABASE TO ORCLDUP
PFILE=F:\oracle\product\10.2.0\admin\orcldup\pfile\INIT.ORA
NOFILENAMECHECK;
最后,RMAN会自动以RESETLOGS方式打开duplicate数据库并重建Redologs,复制完成。
b.异机不同路径结构的复制
(1)初始化参数中重定义文件路径:首先还是要创建辅助实例,修改辅助实例的初始化参数中以*_DEST
结尾的参数,以及其他包含路径的参数确认这些参数设置的路径正确有效。设置DB_FILE_NAME_CONVERT
参数,让其自动转换数据文件路径。设置LOG_FILE_NAME_CONVERT参数,让其自动转换日志文件路径。 www.2cto.com
(2)RMAN连接目标数据库和辅助实例
(3)RMAN>duplicate target database to orcldup;
在duplicate命令中重定义文件路径,步骤如下:
创建辅助实例;RMAN连接目标数据库和辅助实例;运行duplicate命令。
RMAN>duplicate target database to orcldup
PFILE=F:\oracle\product\10.2.0\admin\orcldup\pfile\INIT.ORA
db_file_name_cOnvert=('F:\oracle\product\10.2.0\oradata\orcl','F:\oracle\product\10.2.0\oradata\orcldup')
LOGFILE
'F:\oracle\product\10.2.0\oradata\orcldup\REDO01.LOG' 20M,
'F:\oracle\product\10.2.0\oradata\orcldup\REDO02.LOG' 20M,
'F:\oracle\product\10.2.0\oradata\orcldup\REDO03.LOG' 20M;
#使用set newname命令重命名数据文件:创建辅助实例;RMAN连接目标数据库和辅助实例;SET NEWNAME
命令设置数据文件路径。DUPLICATE命令复制数据库。
RMAN>RUN{
#SET NEW FILENAMES FOR THE DATAFILES
SET NEWNAME FOR DATAFILE 1 TO 'F:\oracle\product\10.2.0\oradata\orcldup\SYSTEM01.DBF';
SET NEWNAME FOR DATAFILE 1 TO 'F:\oracle\product\10.2.0\oradata\orcldup\UNDOTBS01.DBF';
#ISSUE THE DUPLICATE COMMAND
duplicate target database to orcldup
#CREATE AT LEAST TWO ONLINE REDO LOG GROUPS
使用CONFIGURE AUXNAME 命令重命名数据文件
#configure the new desired filenames
configure auxname for datafile 1 to 'F:\oracle\product\10.2.0\oradata\orcldup\SYSTEM01.DBF'
configure auxname for datafile 1 to 'F:\oracle\product\10.2.0\oradata\orcldup\undotbs01.DBF' www.2cto.com
configure auxname命令是在run块外执行的,而且建议在duplicate命令执行玩之后,清楚configure
auxname,这样就不会对未来的类似操作造成影响。
#clear specified auxiliary names for the datafiles
configure auxname for datafile 1 clear;
configure auxname for datafile 2 clear;
三、CATALOG模式本地完整复制目标数据库ORCL到副本数据库ORCLDUP
1.创建辅助实例
a.创建辅助实例的密钥文件
C:/>orapwd file=F:\oracle\product\10.2.0\db_1\database\PWDorcldup.ora password=lyn
entires=30
b.创建OracleService
C:/>oradim -new -sid orcldup -startmode manual
c.配置初始化参数文件
F:\oracle\product\10.2.0\admin>mkdir orcldup
F:\oracle\product\10.2.0\admin\orcldup>mkdir adump bdump cdump pfile udump
NOTE:辅助实例的初始化参数中的BLOCK_SIZE必须与目标数据库相同,如果目标库的参数文件
包括DB_BLOCK_SIZE参数,你必须指定辅助实例中该参数的值与目标库相同,如果目标DB中没有,
辅助实例也不必指定。如果duplicate db与target db在同一台机器上,Duplicate数据库的DB_NAME
不能与目标数据库相同。如果Duplicate数据库与目标数据库不爱同一台机器,需要注意各项初始化
参数中的路径,必须确认该路径对于Duplicate数据库有效。
初始化参数文件init.ora的内容如下:
DB_NAME='orcldup'
control_files='F:\oracle\product\10.2.0\oradata\orcldup\control01.ctl','F:\oracle\product\10.2.0\oradata\orcldup\control02.ctl','F:\oracle\product\10.2.0\oradata\orcldup\control03.ctl'
shared_pool_size=200000000
db_block_size=8192 www.2cto.com
db_file_name_cOnvert=('F:\oracle\product\10.2.0\oradata\orcl','F:\oracle\product\10.2.0\oradata\orcldup')
log_file_name_cOnvert=('F:\oracle\product\10.2.0\oradata\orcl','F:\oracle\product\10.2.0\oradata\orcldup')
audit_file_dest='F:\oracle\product\10.2.0\admin\orcldup\adump'
background_dump_dest='F:\oracle\product\10.2.0\admin\orcldup\bdump'
compatible='10.2.0.3.0'
core_dump_dest='F:\oracle\product\10.2.0\admin\orcldup\cdump'
user_dump_dest='F:\oracle\product\10.2.0\admin\orcldup\udump'
根据初始化参数文件inti.ora创建spfile
C:/>set oracle_sid=orcldup
C:/>sqlplus / as sysdba
SQL>create spfile from pfile='F:\oracle\product\10.2.0\db_1\database\init.ora';
SQL>startup nomount
d.配置监听和网络服务名
修改listener.ora文件,添加如下内容
(SID_DESC =
(GLOBAL_DBNAME = orcldup)
(ORACLE_HOME = F:\oracle\product\10.2.0\db_1)
(SID_NAME = orcldup)
)
修改tnsnames.ora文件,添加如下内容
ORCLDUP =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.29.38)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCLDUP)
)
)
重启监听 C:/>LSNRCTL RELOAD
2.启动目标数据库到MOUNT或OPEN模式
C:/>sqlplus / as sysdba
SQL>STARTUP www.2cto.com
连接目标数据库是否存在可用备份:
C:\>rman target sys/lyn@orcl catalog rman/rman@catalog
Recovery Manager: Release 10.2.0.3.0 - Production on Thu Aug 9 11:37:04 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1304585157)
connected to recovery catalog database
RMAN> list backup of database;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
457 Full 185.74M DISK 00:00:55 11-JUN-12
BP Key: 461 Status: AVAILABLE Compressed: YES Tag: TAG20120611T13464
3
Piece Name: F:\BACKUP_3GND96A4_1_1
List of Datafiles in backup set 457
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 5145206 11-JUN-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF www.2cto.com
2 Full 5145206 11-JUN-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS2.DBF
3 Full 5145206 11-JUN-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF
4 Full 5145206 11-JUN-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF
5 Full 5145206 11-JUN-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF
6 Full 5145206 11-JUN-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ORADATA1.DBF
7 Full 5145206 11-JUN-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ORADATA2.DBF
8 Full 5145206 11-JUN-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM02.DBF
9 Full 5145206 11-JUN-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\MYIDX01.DBF
10 Full 5145206 11-JUN-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS02.DBF www.2cto.com
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
959 Full 1.07G DISK 00:01:18 02-AUG-12
BP Key: 975 Status: AVAILABLE Compressed: NO Tag: TAG20120802T151438
Piece Name: F:\BACKUP_3NNHL3AV_1_1
List of Datafiles in backup set 959
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
4 Full 8716227 02-AUG-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
961 Full 96.00K DISK 00:00:00 02-AUG-12
BP Key: 976 Status: AVAILABLE Compressed: NO Tag: TAG20120802T151734
Piece Name: F:\BACKUP_3PNHL3GE_1_1
List of Datafiles in backup set 961
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
13 Full 8716370 02-AUG-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ORADATA3.DBF
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1323 Full 3.10G DISK 00:06:50 08-AUG-12
BP Key: 1327 Status: AVAILABLE Compressed: NO Tag: TAG20120808T12132
3
Piece Name: F:\BACKUP_4BNI4IV3_1_1
List of Datafiles in backup set 1323
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 9008324 08-AUG-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF
2 Full 9008324 08-AUG-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS2.DBF www.2cto.com
3 Full 9008324 08-AUG-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX
4 Full 9008324 08-AUG-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF
5 Full 9008324 08-AUG-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF
6 Full 9008324 08-AUG-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ORADATA1.DBF
7 Full 9008324 08-AUG-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ORADATA2.DBF
8 Full 9008324 08-AUG-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM02.DBF
9 Full 9008324 08-AUG-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\MYIDX01.DBF
10 Full 9008324 08-AUG-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS02.DBF
11 Full 9008324 08-AUG-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ASM_LMT.DBF
12 Full 9008324 08-AUG-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\PERFSTAT.DBF
13 Full 9008324 08-AUG-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ORADATA3.DBF
14 Full 9008324 08-AUG-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\STREAMS_TBS.DBF
15 Full 9008324 08-AUG-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\ORCL\DATAFILE\O1_MF_USER123_81MTG1GN_.DBF
16 Full 9008324 08-AUG-12 F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\GGTBS.DBF
没有备份就没法恢复,而恢复时DUPLICATE的主要工作,如果没有,赶紧创建备份集思密达。
NOTE:如果创建duplicate数据库到其他服务器,那么必须将备份集和相关的归档文件复制到辅助实
例所在的服务器适当路径下,以保证RMAN在向DUPLICATE数据库恢复数据文件时,能够读取到备份集。 www.2cto.com
3.执行恢复
C:\>rman target sys/lyn@orcl catalog rman/rman@catalog auxiliary sys/lyn@orcldup
Recovery Manager: Release 10.2.0.3.0 - Production on Thu Aug 9 11:38:40 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1304585157)
connected to recovery catalog database
connected to auxiliary database: ORCLDUP (not mounted)
运行duplicate命令之前至少指定一个辅助通道,分配通道在RMAN的RUN块中指定,通过ALLOCATE
AUXILIARY CHANNEL命令,
RUN{
#手工分配通道类型为sbt(磁带);
allocate auxiliary channel ch1 device type sbt;
#手工分配通道类型为disk
allocate auxiliary channel aux1 device type disk;
allocate auxiliary channel aux2 device type disk;
allocate auxiliary channel aux3 device type disk;
....
DUPLICATE TARGET DATABASE TO ORCLDUP;
}
4.执行DUPLICATE命令
RMAN>DUPLICATE TARGET DATABASE TO ORCLDUP;
Starting Duplicate Db at 09-AUG-12
starting full resync of recovery catalog
full resync complete
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=36 devtype=DISK
contents of Memory Script:
{
set until scn 9085645;
set newname for datafile 1 to
"F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\SYSTEM01.DBF";
set newname for datafile 2 to
"F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\UNDOTBS2.DBF";
set newname for datafile 3 to www.2cto.com
"F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\SYSAUX01.DBF";
set newname for datafile 4 to
"F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\USERS01.DBF";
set newname for datafile 5 to
"F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\EXAMPLE01.DBF";
set newname for datafile 6 to
"F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\ORADATA1.DBF";
set newname for datafile 7 to
"F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\ORADATA2.DBF";
set newname for datafile 8 to
"F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\SYSTEM02.DBF";
set newname for datafile 9 to
"F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\MYIDX01.DBF";
set newname for datafile 10 to
"F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\UNDOTBS02.DBF";
set newname for datafile 11 to
"F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\ASM_LMT.DBF";
set newname for datafile 12 to
"F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\PERFSTAT.DBF";
set newname for datafile 13 to
"F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\ORADATA3.DBF";
set newname for datafile 14 to
"F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\STREAMS_TBS.DBF";
set newname for datafile 15 to
"F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\ORCL\DATAFILE\O1_MF_USER123_81MTG1GN_
.DBF";
set newname for datafile 16 to
"F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\GGTBS.DBF";
restore
check readonly
clone database
;
} www.2cto.com
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
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
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 09-AUG-12
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 00001 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\SYSTEM01.DBF
restoring datafile 00002 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\UNDOTBS2.DBF
restoring datafile 00003 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\SYSAUX01.DBF
restoring datafile 00004 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\USERS01.DBF
restoring datafile 00005 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\EXAMPLE01.DBF
restoring datafile 00006 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\ORADATA1.DBF
restoring datafile 00007 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\ORADATA2.DBF
restoring datafile 00008 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\SYSTEM02.DBF
restoring datafile 00009 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\MYIDX01.DBF
restoring datafile 00010 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\UNDOTBS02.DBF
restoring datafile 00011 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\ASM_LMT.DBF
restoring datafile 00012 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\PERFSTAT.DBF
restoring datafile 00013 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\ORADATA3.DBF
restoring datafile 00014 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\STREAMS_TBS.DBF
restoring datafile 00015 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\ORCL\DATAFI
LE\O1_MF_USER123_81MTG1GN_.DBF www.2cto.com
restoring datafile 00016 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\GGTBS.DBF
channel ORA_AUX_DISK_1: reading from backup piece F:\BACKUP_4BNI4IV3_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=F:\BACKUP_4BNI4IV3_1_1 tag=TAG20120808T121323
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:06:16
Finished restore at 09-AUG-12
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCLDUP" RESETLOGS ARCHIVE
LOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\REDO01.LOG' ) SIZE 50 M
REUSE,
GROUP 2 ( 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\REDO02.LOG' ) SIZE 50 M
REUSE,
GROUP 3 ( 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\REDO03.LOG' ) SIZE 50 M
REUSE
DATAFILE www.2cto.com
'F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\SYSTEM01.DBF'
CHARACTER SET ZHS16GBK
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
released channel: ORA_AUX_DISK_1
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=790863609 filename=F:\ORACLE\PRODUCT\10.2.0\OR
ADATA\ORCLDUP\UNDOTBS2.DBF
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=790863609 filename=F:\ORACLE\PRODUCT\10.2.0\OR
ADATA\ORCLDUP\SYSAUX01.DBF
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=790863610 filename=F:\ORACLE\PRODUCT\10.2.0\OR
ADATA\ORCLDUP\USERS01.DBF
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=790863610 filename=F:\ORACLE\PRODUCT\10.2.0\OR
ADATA\ORCLDUP\EXAMPLE01.DBF
datafile 6 switched to datafile copy
input datafile copy recid=5 stamp=790863611 filename=F:\ORACLE\PRODUCT\10.2.0\OR
ADATA\ORCLDUP\ORADATA1.DBF www.2cto.com
datafile 7 switched to datafile copy
input datafile copy recid=6 stamp=790863611 filename=F:\ORACLE\PRODUCT\10.2.0\OR
ADATA\ORCLDUP\ORADATA2.DBF
datafile 8 switched to datafile copy
input datafile copy recid=7 stamp=790863611 filename=F:\ORACLE\PRODUCT\10.2.0\OR
ADATA\ORCLDUP\SYSTEM02.DBF
datafile 9 switched to datafile copy
input datafile copy recid=8 stamp=790863611 filename=F:\ORACLE\PRODUCT\10.2.0\OR
ADATA\ORCLDUP\MYIDX01.DBF
datafile 10 switched to datafile copy
input datafile copy recid=9 stamp=790863611 filename=F:\ORACLE\PRODUCT\10.2.0\OR
ADATA\ORCLDUP\UNDOTBS02.DBF
datafile 11 switched to datafile copy
input datafile copy recid=10 stamp=790863612 filename=F:\ORACLE\PRODUCT\10.2.0\O
RADATA\ORCLDUP\ASM_LMT.DBF
datafile 12 switched to datafile copy
input datafile copy recid=11 stamp=790863612 filename=F:\ORACLE\PRODUCT\10.2.0\O
RADATA\ORCLDUP\PERFSTAT.DBF
datafile 13 switched to datafile copy
input datafile copy recid=12 stamp=790863612 filename=F:\ORACLE\PRODUCT\10.2.0\O
RADATA\ORCLDUP\ORADATA3.DBF
datafile 14 switched to datafile copy
input datafile copy recid=13 stamp=790863612 filename=F:\ORACLE\PRODUCT\10.2.0\O
RADATA\ORCLDUP\STREAMS_TBS.DBF
datafile 15 switched to datafile copy
input datafile copy recid=14 stamp=790863612 filename=F:\ORACLE\PRODUCT\10.2.0\O
RADATA\ORCLDUP\ORCL\DATAFILE\O1_MF_USER123_81MTG1GN_.DBF
datafile 16 switched to datafile copy
input datafile copy recid=15 stamp=790863613 filename=F:\ORACLE\PRODUCT\10.2.0\O
RADATA\ORCLDUP\GGTBS.DBF
contents of Memory Script:
{
set until scn 9085645;
recover
clone database
delete archivelog
; www.2cto.com
}
executing Memory Script
executing command: SET until clause
Starting recover at 09-AUG-12
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=35 devtype=DISK
starting media recovery
archive log thread 1 sequence 266 is already on disk as file C:\DATAGUARD\DEMO\O
RCL\ARCHIVELOG\LOG1_266_784480114.ARC
archive log thread 1 sequence 267 is already on disk as file C:\DATAGUARD\DEMO\O
RCL\ARCHIVELOG\LOG1_267_784480114.ARC
archive log thread 1 sequence 268 is already on disk as file C:\DATAGUARD\DEMO\O
RCL\ARCHIVELOG\LOG1_268_784480114.ARC
archive log filename=C:\DATAGUARD\DEMO\ORCL\ARCHIVELOG\LOG1_266_784480114.ARC th
read=1 sequence=266
archive log filename=C:\DATAGUARD\DEMO\ORCL\ARCHIVELOG\LOG1_267_784480114.ARC th
read=1 sequence=267
archive log filename=C:\DATAGUARD\DEMO\ORCL\ARCHIVELOG\LOG1_268_784480114.ARC th
read=1 sequence=268
media recovery complete, elapsed time: 00:00:28
Finished recover at 09-AUG-12
contents of Memory Script:
{ www.2cto.com
shutdown clone;
startup clone nomount ;
}
executing Memory Script
最后以OPEN RESETLOGS方式打开数据库,复制完成。
contents of Memory Script:
{
Alter clone database open;
}
executing Memory Script
database opened
5.验证结果
SQL>CONN SYSTEM/LYN@ORCLDUP
ORCLDUP>select name from v$tablespace;
NAME
------------------------------
SYSTEM
UNDOTBS1
SYSAUX
USERS
EXAMPLE
MYSPACE
MYINDEX
UNDOTBS2
ASM_LMT_TS
PERFSTAT
STREAMS_TBS
NAME
------------------------------
USER123
GG_TBS
TEMP
14 rows selected.
ORCLDUP>select name from v$datafile;
NAME www.2cto.com
--------------------------------------------------------------------------------
F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\SYSTEM01.DBF
F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\UNDOTBS2.DBF
F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\SYSAUX01.DBF
F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\USERS01.DBF
F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\EXAMPLE01.DBF
F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\ORADATA1.DBF
F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\ORADATA2.DBF
F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\SYSTEM02.DBF
F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\MYIDX01.DBF
F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\UNDOTBS02.DBF
F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\ASM_LMT.DBF
NAME
--------------------------------------------------------------------------------
F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\PERFSTAT.DBF
F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\ORADATA3.DBF
F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\STREAMS_TBS.DBF
F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\ORCL\DATAFILE\O1_MF_USER123_81MTG1GN_.DBF
F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCLDUP\GGTBS.DBF
16 rows selected.
OK,表空间和数据文件都有了,创建成功。
四、复制过程中的一些高级选项
1.跳过表空间:跳过只读表空间,只需要在DUPLICATE梦里时指定SKIP READONLY子句,而对于离线
表空间,在执行DUPLICATE命令之前将其设置为OFFLINE NORMAL状态即可,这样DUPLICATE命令执行
恢复时,就会跳过只读或离线表空间对应的数据文件。如果表空间既不是只读也不是离线,也可以
通过SKIP TABLESPACE tbsname跳过,有多个表空间,用逗号隔开即是。
2.重命名duplicate数据库中文件
a.创建过程中重命名控制文件:在duplicate命令中指定CONTROL_FILES参数的名称和位置。
b.创建过程中重命名在线日志文件
RMAN>duplicate target database to orcldup
PFILE=F:\oracle\product\10.2.0\admin\orcldup\pfile\INIT.ORA
db_file_name_cOnvert=('F:\oracle\product\10.2.0\oradata\orcl','F:\oracle\product\10.2.0\oradata\orcldup')
LOGFILE www.2cto.com
'F:\oracle\product\10.2.0\oradata\orcldup\REDO01.LOG' 20M,
'F:\oracle\product\10.2.0\oradata\orcldup\REDO02.LOG' 20M,
'F:\oracle\product\10.2.0\oradata\orcldup\REDO03.LOG' 20M;
c.创建过程中重命名数据文件
RMAN>RUN{
#SET NEW FILENAMES FOR THE DATAFILES
SET NEWNAME FOR DATAFILE 1 TO 'F:\oracle\product\10.2.0\oradata\orcldup\SYSTEM01.DBF';
SET NEWNAME FOR DATAFILE 1 TO 'F:\oracle\product\10.2.0\oradata\orcldup\UNDOTBS01.DBF'; www.2cto.com
#ISSUE THE DUPLICATE COMMAND
duplicate target database to orcldup
}必须指定NOFILENAMECHECK选项避免oracle自动识别。
d.创建过程中重命名临时文件
SET NEWNAME FOR TEMPFILE 10 TO 'F:\oracle\product\10.2.0\oradata\orcldup\TEMP01.DBF';
e.同步副本数据库
对于非standby方式创建的duplicate数据库并不能实现常规意义上的同步,只不过重新执行一次
DUPLICATE命令。如果你不需要配置辅助实例,你需要只是把RMAN链接到目标数据库和辅助实例
(必须启动到NOMOUNT状态),然后重新执行duplicate即可。