本文共 12028 字,大约阅读时间需要 40 分钟。
11g的RMAN duplicate 可以通过Active databaseduplicate和Backup-based duplicate两种方法实现。这里的测试使用的是Active databaseduplicate,因为Active database duplicate 功能强大,不需要先把目标数据库进行rman备份,只要目标数据库处于归档模式下即可直接通过网络对数据库进行copy,且copy完成后自动open数据库。这对于大数据特别是T级别的数据库来说优点非常明显,复制前不需要进行备份,减少了备份和传送备份的时间,同时节省备份空间。下面来进行具体的duplicate操作。
监听,口令文件配置,pfile配置,创建clone库相关目录等过程同基于备份的RMAN复制一样
SQL>startup pfile=$ORACLE_HOME/dbs/initclonedb.ora nomount;ORACLEinstance started. TotalSystem Global Area 630501376 bytesFixedSize 2215984 bytesVariableSize 184553424 bytesDatabaseBuffers 440401920 bytesRedoBuffers 3330048 bytes
[oracle@HE4~]$ rman target sys/MANAGER@orcl auxiliarysys/MANAGER@clonedb RecoveryManager: Release 11.2.0.1.0 - Production on Thu Jan 28 19:57:31 2016 Copyright(c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. connectedto target database: ORCL (DBID=1426154421)connectedto auxiliary database: CLONEDB (not mounted)RMAN> duplicate target database to clonedb from active database; (这里是异机异构恢复,如果是同结构的参数会报错,需添加nofilenamecheck,谨慎使用,防止文件被覆盖)Starting DuplicateDb at 28-JAN-16using targetdatabase control file instead of recovery catalogallocated channel:ORA_AUX_DISK_1channelORA_AUX_DISK_1: SID=20 device type=DISK contents of MemoryScript:{ sql clone "create spfile frommemory";}executing MemoryScript sql statement:create spfile from memory contents of MemoryScript:{ shutdown clone immediate; startup clone nomount;}executing MemoryScript Oracle instance shutdown connected toauxiliary database (not started)Oracle instancestarted Total System GlobalArea 630501376 bytes Fixed Size 2215984 bytesVariable Size 188747728 bytesDatabaseBuffers 436207616 bytesRedo Buffers 3330048 bytes contents of MemoryScript:{ sql clone "alter system set db_name = ''ORCL'' comment= ''Modified by RMAN duplicate''scope=spfile"; sql clone "alter system set db_unique_name = ''CLONEDB'' comment= ''Modified by RMAN duplicate''scope=spfile"; shutdown clone immediate; startup clone force nomount backup as copy current controlfile auxiliaryformat '/u01/app/oracle/oradata/clonedb/control01.ctl'; restore clone controlfile to '/u01/app/oracle/oradata/clonedb/control02.ctl' from '/u01/app/oracle/oradata/clonedb/control01.ctl'; alter clone database mount;}executing MemoryScript sql statement: altersystem set db_name = ''ORCL'' comment= ''Modified by RMANduplicate'' scope=spfile sql statement: altersystem set db_unique_name = ''CLONEDB'' comment= ''Modified by RMANduplicate'' scope=spfile Oracle instance shutdown Oracle instancestarted Total System GlobalArea 630501376 bytes Fixed Size 2215984 bytesVariable Size 188747728 bytesDatabaseBuffers 436207616 bytesRedo Buffers 3330048 bytes Starting backup at28-JAN-16allocated channel:ORA_DISK_1channel ORA_DISK_1:SID=36 device type=DISKchannel ORA_DISK_1:starting datafile copycopying currentcontrol fileoutput filename=/u01/app/oracle/product/11gr2/db_1/dbs/snapcf_orcl.ftag=TAG20160128T204953 RECID=5 STAMP=902350193channel ORA_DISK_1:datafile copy complete, elapsed time: 00:00:03Finished backup at28-JAN-16 Starting restore at28-JAN-16allocated channel:ORA_AUX_DISK_1channelORA_AUX_DISK_1: SID=18 device type=DISK channelORA_AUX_DISK_1: copied control file copyFinished restore at28-JAN-16 database mounted contents of MemoryScript:{ set newname for datafile 1 to "/u01/app/oracle/oradata/clonedb/system01.dbf"; set newname for datafile 2 to "/u01/app/oracle/oradata/clonedb/sysaux01.dbf"; set newname for datafile 3 to "/u01/app/oracle/oradata/clonedb/undotbs01.dbf"; set newname for datafile 4 to "/u01/app/oracle/oradata/clonedb/users01.dbf"; set newname for datafile 5 to "/u01/app/oracle/oradata/clonedb/example01.dbf"; set newname for datafile 6 to "/u01/app/oracle/oradata/clonedb/heleitbs01.dbf"; backup as copy reuse datafile 1 auxiliary format "/u01/app/oracle/oradata/clonedb/system01.dbf" datafile 2 auxiliary format "/u01/app/oracle/oradata/clonedb/sysaux01.dbf" datafile 3 auxiliary format "/u01/app/oracle/oradata/clonedb/undotbs01.dbf" datafile 4 auxiliary format "/u01/app/oracle/oradata/clonedb/users01.dbf" datafile 5 auxiliary format "/u01/app/oracle/oradata/clonedb/example01.dbf" datafile 6 auxiliary format "/u01/app/oracle/oradata/clonedb/heleitbs01.dbf" ; sql 'alter system archive log current';}executing MemoryScript 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 backup at28-JAN-16using channelORA_DISK_1channel ORA_DISK_1:starting datafile copyinput datafile filenumber=00001 name=/u01/app/oracle/oradata/orcl/system01.dbfoutput filename=/u01/app/oracle/oradata/clonedb/system01.dbf tag=TAG20160128T205002channel ORA_DISK_1:datafile copy complete, elapsed time: 00:00:59channel ORA_DISK_1:starting datafile copyinput datafile filenumber=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbfoutput filename=/u01/app/oracle/oradata/clonedb/sysaux01.dbf tag=TAG20160128T205002channel ORA_DISK_1:datafile copy complete, elapsed time: 00:00:35channel ORA_DISK_1:starting datafile copyinput datafile filenumber=00006 name=/u01/app/oracle/oradata/orcl/heleitbs01.dbfoutput filename=/u01/app/oracle/oradata/clonedb/heleitbs01.dbf tag=TAG20160128T205002channel ORA_DISK_1:datafile copy complete, elapsed time: 00:00:16channel ORA_DISK_1:starting datafile copyinput datafile filenumber=00005 name=/u01/app/oracle/oradata/orcl/example01.dbfoutput filename=/u01/app/oracle/oradata/clonedb/example01.dbf tag=TAG20160128T205002channel ORA_DISK_1:datafile copy complete, elapsed time: 00:00:15channel ORA_DISK_1:starting datafile copyinput datafile filenumber=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbfoutput filename=/u01/app/oracle/oradata/clonedb/undotbs01.dbf tag=TAG20160128T205002channel ORA_DISK_1:datafile copy complete, elapsed time: 00:00:08channel ORA_DISK_1:starting datafile copyinput datafile filenumber=00004 name=/u01/app/oracle/oradata/orcl/users01.dbfoutput filename=/u01/app/oracle/oradata/clonedb/users01.dbf tag=TAG20160128T205002channel ORA_DISK_1:datafile copy complete, elapsed time: 00:00:01Finished backup at28-JAN-16 sql statement: altersystem archive log current contents of MemoryScript:{ backup as copy reuse archivelog like "/u01/archivelog/1_13_898373685.dbf" auxiliary format "/u01/archivelog/1_13_898373685.dbf" ; catalog clone archivelog "/u01/archivelog/1_13_898373685.dbf"; switch clone datafile all;}executing MemoryScript Starting backup at28-JAN-16using channelORA_DISK_1channel ORA_DISK_1:starting archived log copyinput archived logthread=1 sequence=13 RECID=9 STAMP=902350337output filename=/u01/archivelog/1_13_898373685.dbf RECID=0 STAMP=0channel ORA_DISK_1:archived log copy complete, elapsed time: 00:00:01Finished backup at28-JAN-16 cataloged archivedlogarchived log filename=/u01/archivelog/1_13_898373685.dbf RECID=9 STAMP=902350338 datafile 1 switchedto datafile copyinput datafile copyRECID=5 STAMP=902350338 file name=/u01/app/oracle/oradata/clonedb/system01.dbfdatafile 2 switchedto datafile copyinput datafile copyRECID=6 STAMP=902350338 file name=/u01/app/oracle/oradata/clonedb/sysaux01.dbfdatafile 3 switchedto datafile copyinput datafile copyRECID=7 STAMP=902350338 file name=/u01/app/oracle/oradata/clonedb/undotbs01.dbfdatafile 4 switchedto datafile copyinput datafile copyRECID=8 STAMP=902350338 file name=/u01/app/oracle/oradata/clonedb/users01.dbfdatafile 5 switchedto datafile copyinput datafile copyRECID=9 STAMP=902350338 file name=/u01/app/oracle/oradata/clonedb/example01.dbfdatafile 6 switchedto datafile copyinput datafile copyRECID=10 STAMP=902350338 filename=/u01/app/oracle/oradata/clonedb/heleitbs01.dbf contents of MemoryScript:{ set until scn 1028975; recover clone database delete archivelog ;}executing MemoryScript executing command:SET until clause Starting recover at28-JAN-16using channelORA_AUX_DISK_1 starting mediarecovery archived log forthread 1 with sequence 13 is already on disk as file/u01/archivelog/1_13_898373685.dbfarchived log filename=/u01/archivelog/1_13_898373685.dbf thread=1 sequence=13media recoverycomplete, elapsed time: 00:00:00Finished recover at28-JAN-16 contents of MemoryScript:{ shutdown clone immediate; startup clone nomount; sql clone "alter system set db_name = ''CLONEDB'' comment= ''Reset to original value by RMAN''scope=spfile"; sql clone "alter system reset db_unique_name scope=spfile"; shutdown clone immediate; startup clone nomount;}executing MemoryScript database dismountedOracle instance shutdown connected toauxiliary database (not started)Oracle instancestarted Total System GlobalArea 630501376 bytes Fixed Size 2215984 bytesVariable Size 188747728 bytesDatabaseBuffers 436207616 bytesRedo Buffers 3330048 bytes sql statement: altersystem set db_name = ''CLONEDB'' comment= ''Reset to originalvalue by RMAN'' scope=spfile sql statement: altersystem reset db_unique_name scope=spfile Oracle instance shutdown connected toauxiliary database (not started)Oracle instancestarted Total System GlobalArea 630501376 bytes Fixed Size 2215984 bytesVariable Size 188747728 bytesDatabaseBuffers 436207616 bytesRedo Buffers 3330048 bytessql statement:CREATE CONTROLFILE REUSE SET DATABASE "CLONEDB" RESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 ( '/u01/app/oracle/oradata/clonedb/redo01.log' ) SIZE 50 M REUSE, GROUP 2 ( '/u01/app/oracle/oradata/clonedb/redo02.log' ) SIZE 50 M REUSE, GROUP 3 ( '/u01/app/oracle/oradata/clonedb/redo03.log' ) SIZE 50 M REUSE DATAFILE '/u01/app/oracle/oradata/clonedb/system01.dbf' CHARACTER SET ZHS16GBK contents of MemoryScript:{ set newname for tempfile 1 to "/u01/app/oracle/oradata/clonedb/temp01.dbf"; switch clone tempfile all; catalog clone datafilecopy "/u01/app/oracle/oradata/clonedb/sysaux01.dbf", "/u01/app/oracle/oradata/clonedb/undotbs01.dbf", "/u01/app/oracle/oradata/clonedb/users01.dbf", "/u01/app/oracle/oradata/clonedb/example01.dbf", "/u01/app/oracle/oradata/clonedb/heleitbs01.dbf"; switch clone datafile all;}executing MemoryScript executing command:SET NEWNAME renamed tempfile 1to /u01/app/oracle/oradata/clonedb/temp01.dbf in control file cataloged datafilecopydatafile copy filename=/u01/app/oracle/oradata/clonedb/sysaux01.dbf RECID=1 STAMP=902350346cataloged datafilecopydatafile copy filename=/u01/app/oracle/oradata/clonedb/undotbs01.dbf RECID=2 STAMP=902350346cataloged datafilecopydatafile copy filename=/u01/app/oracle/oradata/clonedb/users01.dbf RECID=3 STAMP=902350346cataloged datafilecopydatafile copy filename=/u01/app/oracle/oradata/clonedb/example01.dbf RECID=4 STAMP=902350346cataloged datafilecopydatafile copy filename=/u01/app/oracle/oradata/clonedb/heleitbs01.dbf RECID=5 STAMP=902350346 datafile 2 switchedto datafile copyinput datafile copyRECID=1 STAMP=902350346 file name=/u01/app/oracle/oradata/clonedb/sysaux01.dbfdatafile 3 switchedto datafile copyinput datafile copyRECID=2 STAMP=902350346 file name=/u01/app/oracle/oradata/clonedb/undotbs01.dbfdatafile 4 switchedto datafile copyinput datafile copyRECID=3 STAMP=902350346 file name=/u01/app/oracle/oradata/clonedb/users01.dbfdatafile 5 switchedto datafile copyinput datafile copyRECID=4 STAMP=902350346 file name=/u01/app/oracle/oradata/clonedb/example01.dbfdatafile 6 switchedto datafile copyinput datafile copyRECID=5 STAMP=902350346 filename=/u01/app/oracle/oradata/clonedb/heleitbs01.dbf contents of MemoryScript:{ Alter clone database open resetlogs;}executing MemoryScript database openedFinished DuplicateDb at 28-JAN-16
转载地址:http://wjjnx.baihongyu.com/