Cloning A Database On The Same Server Using Rman Duplicate From Active Database

Alejandro Vargas | Principal Support Consultant Oracle Advanced Customer Services

To clone a database using Rman we used to require an existing Rman backup, on 11g we can clone databases using the “from active” database option. In this case we do not require an existing backup, the active datafiles will be used as the source for the clone. In order to clone with the source database open it must be on archivelog mode. Otherwise we can make the clone mounting the source database, as shown in this example. These are the steps required to complete the clone:

Configure The Network ......................................................................................2 Create A Password File For The New Database................................................3 Create An Init.Ora For The New Database.........................................................3 Create The Admin Directory For The New Database ........................................4 Shutdown And Startup Mount The Source Database.........................................4 Startup Nomount The New Database ................................................................4 Connect To The Target (Source) And Auxiliary (New Clone) Databases Using Rman ..................................................................................................................4 Execute The Duplicate Command......................................................................5 Remove The Old Pfile.......................................................................................12 Check The New Database................................................................................12

1/13

ora Network Configuration File: /oracle/app/product/11. SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = redpanda) (ORACLE_HOME = /oracle/app/product/11. ora # Generated by Oracle configuration tools.0/dbhome_1) (SID_NAME = rmancat) ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = redpanda)) ) (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = rmancat)) ) (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = lnx1)(PORT = 1521)) ) ) ADR_BASE_LISTENER = /oracle/app Tnsnames file: redpanda = 2/13 .0/dbhome_1/network/admin/listener.0/dbhome_1) (SID_NAME = redpanda) ) (SID_DESC = (GLOBAL_DBNAME = rmancat) (ORACLE_HOME = /oracle/app/product/11.2.2.2.Cloning A Database On The Same Server Using Rman Duplicate From Active Database Configure The Network We need to configure the network so that there is connectivity to the target (source) database and to the database we want to create (the clone) Listener file: # listener.

Cloning A Database On The Same Server Using Rman Duplicate From Active Database (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = lnx1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = redpanda) ) ) rmancat = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = lnx1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = rmancat) ) ) Create A Password File For The New Database [oracle@lnx1 dbs]$ orapwd file=orapwredpanda password=oracle Create An Init.memory_target=262144000 *.db_create_file_dest='/oracle/app/oradata' *.dispatchers='(PROTOCOL=TCP) (SERVICE=redpandaXDB)' *.audit_file_dest='/oracle/app/admin/redpanda/adump' *.db_recovery_file_dest_size=4039114752 *.0.processes=150 *.db_name='redpanda' *.audit_trail='db' *.0' #*.Ora For The New Database Create the pfile using create pfile from spfile from the source database.diagnostic_dest='/oracle/app' *.open_cursors=300 *.db_block_size=8192 *.2.db_recovery_file_dest='/oracle/app/flash_recovery_area' *.remote_login_passwordfile='EXCLUSIVE' 3/13 .0.compatible='11.control_files='’ *. then edit it changing all occurrences of old database name to new name *.db_domain='' *.

0 . ORACLE instance shut down. All rights reserved. SQL> startup mount ORACLE instance started. Connect To The Target (Source) And Auxiliary (New Clone) Databases Using Rman [oracle@lnx1 dbs]$ Rman target sys/oracle@rmancat auxiliary sys/oracle@redpanda Recovery Manager: Release 11.2. Oracle and/or its affiliates. not open) connected to auxiliary database: REDPANDA (not mounted) 4/13 .0. Startup Nomount The New Database SQL> startup nomount ORACLE instance started.undo_tablespace='UNDOTBS1' Create The Admin Directory For The New Database mkdir –p /oracle/app/admin/redpanda/adump Shutdown And Startup Mount The Source Database This is required if the source database is in no archivelog mode. Database closed.Cloning A Database On The Same Server Using Rman Duplicate From Active Database *.Production on Sat Mar 20 17:00:45 2010 Copyright (c) 1982. 2009. SQL> shutdown immediate. connected to target database: RMANCAT (DBID=3799896238. Database dismounted.1.

''/oracle/app/flash_recovery_area/REDPANDA/controlfile/o1_mf_5t9r sv8j_.ctl' '. } executing Memory Script Oracle instance shut down connected to auxiliary database (not started) Oracle instance started Total System Global Area Fixed Size Variable Size Database Buffers Redo Buffers 263639040 bytes 1335892 205524396 54525952 2252800 bytes bytes bytes bytes contents of Memory Script: { sql clone "alter system set control_files = ''/oracle/app/oradata/REDPANDA/controlfile/o1_mf_5t9rsv87_. Starting Duplicate Db at 20-MAR-10 using target database control file instead of recovery catalog allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=19 device type=DISK contents of Memory Script: { sql clone "create spfile from memory". sql clone "alter system set db_name = ''RMANCAT'' comment= ''Modified by RMAN duplicate'' scope=spfile". sql clone "alter system set db_unique_name = 5/13 . startup clone nomount.Cloning A Database On The Same Server Using Rman Duplicate From Active Database Execute The Duplicate Command RMAN> DUPLICATE TARGET DATABASE TO REDPANDA FROM ACTIVE DATABASE. } executing Memory Script sql statement: create spfile from memory contents of Memory Script: { shutdown clone immediate.ctl'' comment= ''Set by RMAN'' scope=spfile".

} executing Memory Script sql statement: alter system set control_files = ''/oracle/app/oradata/REDPANDA/controlfile/o1_mf_5t9rsv87_.ctl''. sql clone "alter system set control_files = ''/oracle/app/oradata/REDPANDA/controlfile/o1_mf_5t9rsv91_. ''/oracle/app/flash_recovery_area/REDPANDA/controlfile/o1_mf_5t9r sv8j_. restore clone controlfile to '/oracle/app/flash_recovery_area/REDPANDA/controlfile/o1_mf_5t9rs v97_. startup clone force nomount backup as copy current controlfile auxiliary format '/oracle/app/oradata/REDPANDA/controlfile/o1_mf_5t9rsv91_. shutdown clone immediate. startup clone nomount.ctl'' comment= ''Set by RMAN'' scope=spfile". alter clone database mount. ''/oracle/app/flash_recovery_area/REDPANDA/controlfile/o1_mf_5t9r sv97_.ctl'.ctl' '.ctl'.Cloning A Database On The Same Server Using Rman Duplicate From Active Database ''REDPANDA'' comment= ''Modified by RMAN duplicate'' scope=spfile".ctl' from '/oracle/app/oradata/REDPANDA/controlfile/o1_mf_5t9rsv91_. shutdown clone immediate.ctl'' comment= ''Set by RMAN'' scope=spfile sql statement: alter system set db_name = ''RMANCAT'' comment= ''Modified by RMAN duplicate'' scope=spfile sql statement: alter system set db_unique_name = ''REDPANDA'' comment= ''Modified by RMAN duplicate'' scope=spfile Oracle instance shut down Oracle instance started Total System Global Area Fixed Size Variable Size Database Buffers Redo Buffers 263639040 bytes 1335892 205524396 54525952 2252800 bytes bytes bytes bytes Starting backup at 20-MAR-10 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=18 device type=DISK channel ORA_DISK_1: starting datafile copy copying current control file 6/13 .

0/dbhome_1/dbs/snapcf_rmancat. new. } executing Memory Script executing command: SET NEWNAME executing command: SET NEWNAME 263639040 bytes 1335892 205524396 54525952 2252800 bytes bytes bytes bytes to to to to new. ''/oracle/app/flash_recovery_area/REDPANDA/controlfile/o1_mf_5t9r sv97_.ctl''.ctl'' comment= ''Set by RMAN'' scope=spfile Oracle instance shut down connected to auxiliary database (not started) Oracle instance started Total System Global Area Fixed Size Variable Size Database Buffers Redo Buffers database mounted contents of Memory Script: { set newname for clone datafile 1 set newname for clone datafile 2 set newname for clone datafile 3 set newname for clone datafile 4 backup as copy reuse datafile 1 auxiliary format new datafile 2 auxiliary format new datafile 3 auxiliary format new datafile 4 auxiliary format new .Cloning A Database On The Same Server Using Rman Duplicate From Active Database output file name=/oracle/app/product/11. new. 7/13 . new.2.f tag=TAG20100320T170124 RECID=3 STAMP=714157285 channel ORA_DISK_1: datafile copy complete. elapsed time: 00:00:03 Finished backup at 20-MAR-10 Starting restore at 20-MAR-10 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=19 device type=DISK channel ORA_AUX_DISK_1: copied control file copy Finished restore at 20-MAR-10 sql statement: alter system set control_files = ''/oracle/app/oradata/REDPANDA/controlfile/o1_mf_5t9rsv91_.

dbf tag=TAG20100320T170146 channel ORA_DISK_1: datafile copy complete. elapsed time: 00:01:15 channel ORA_DISK_1: starting datafile copy input datafile file number=00003 name=/oracle/app/oradata/RMANCAT/datafile/o1_mf_undotbs1_5t9jpqj4 _.dbf output file name=/oracle/app/oradata/REDPANDA/datafile/o1_mf_undotbs1_0al92bc s_. dbf output file name=/oracle/app/oradata/REDPANDA/datafile/o1_mf_system_08l92b7r_ .Cloning A Database On The Same Server Using Rman Duplicate From Active Database executing command: SET NEWNAME executing command: SET NEWNAME Starting backup at 20-MAR-10 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile copy input datafile file number=00001 name=/oracle/app/oradata/RMANCAT/datafile/o1_mf_system_5t9jpq6z_.dbf tag=TAG20100320T170146 channel ORA_DISK_1: datafile copy complete. elapsed time: 00:01:25 channel ORA_DISK_1: starting datafile copy input datafile file number=00002 name=/oracle/app/oradata/RMANCAT/datafile/o1_mf_sysaux_5t9jpqfm_. elapsed time: 00:00:07 channel ORA_DISK_1: starting datafile copy input datafile file number=00004 name=/oracle/app/oradata/RMANCAT/datafile/o1_mf_users_5t9jpqlz_. dbf output file name=/oracle/app/oradata/REDPANDA/datafile/o1_mf_sysaux_09l92bag_ . } executing Memory Script datafile 1 switched to datafile copy 8/13 . dbf tag=TAG20100320T170146 channel ORA_DISK_1: datafile copy complete.dbf tag=TAG20100320T170146 channel ORA_DISK_1: datafile copy complete. elapsed time: 00:00:01 Finished backup at 20-MAR-10 contents of Memory Script: { switch clone datafile all.d bf output file name=/oracle/app/oradata/REDPANDA/datafile/o1_mf_users_0bl92bd3_.

sql clone "alter system reset db_unique_name scope=spfile". } executing Memory Script database dismounted Oracle instance shut down connected to auxiliary database (not started) Oracle instance started 9/13 . sql clone "alter system set db_name = ''REDPANDA'' comment= ''Reset to original value by RMAN'' scope=spfile". startup clone nomount. dbf contents of Memory Script: { recover clone database noredo delete archivelog . } executing Memory Script Starting recover at 20-MAR-10 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=18 device type=DISK Finished recover at 20-MAR-10 contents of Memory Script: { shutdown clone immediate. shutdown clone immediate.Cloning A Database On The Same Server Using Rman Duplicate From Active Database input datafile copy RECID=3 STAMP=714157476 file name=/oracle/app/oradata/REDPANDA/datafile/o1_mf_system_08l92b7r_ .dbf datafile 3 switched to datafile copy input datafile copy RECID=5 STAMP=714157476 file name=/oracle/app/oradata/REDPANDA/datafile/o1_mf_undotbs1_0al92bc s_.dbf datafile 2 switched to datafile copy input datafile copy RECID=4 STAMP=714157476 file name=/oracle/app/oradata/REDPANDA/datafile/o1_mf_sysaux_09l92bag_ .dbf datafile 4 switched to datafile copy input datafile copy RECID=6 STAMP=714157476 file name=/oracle/app/oradata/REDPANDA/datafile/o1_mf_users_0bl92bd3_. startup clone nomount.

catalog clone datafilecopy "/oracle/app/oradata/REDPANDA/datafile/o1_mf_sysaux_09l92bag_. GROUP 3 SIZE 50 M DATAFILE '/oracle/app/oradata/REDPANDA/datafile/o1_mf_system_08l92b7r_. switch clone tempfile all.d bf' CHARACTER SET WE8MSWIN1252 contents of Memory Script: { set newname for clone tempfile 1 to new. GROUP 2 SIZE 50 M . dbf".Cloning A Database On The Same Server Using Rman Duplicate From Active Database Total System Global Area Fixed Size Variable Size Database Buffers Redo Buffers 263639040 bytes 1335892 205524396 54525952 2252800 bytes bytes bytes bytes sql statement: alter system set db_name = ''REDPANDA'' comment= ''Reset to original value by RMAN'' scope=spfile sql statement: alter system reset Oracle instance shut down connected to auxiliary database (not started) Oracle instance started Total System Global Area 263639040 bytes db_unique_name scope=spfile Fixed Size 1335892 bytes Variable Size 205524396 bytes Database Buffers 54525952 bytes Redo Buffers 2252800 bytes sql statement: CREATE CONTROLFILE REUSE SET DATABASE "REDPANDA" RESETLOGS NOARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 SIZE 50 M . "/oracle/app/oradata/REDPANDA/datafile/o1_mf_undotbs1_0al92bcs_.dbf ". 10/13 .

dbf RECID=1 STAMP=714157503 cataloged datafile copy datafile copy file name=/oracle/app/oradata/REDPANDA/datafile/o1_mf_undotbs1_0al92bc s_.dbf datafile 4 switched to datafile copy input datafile copy RECID=3 STAMP=714157503 file name=/oracle/app/oradata/REDPANDA/datafile/o1_mf_users_0bl92bd3_. dbf contents of Memory Script: { Alter clone database open resetlogs. switch clone datafile all.tmp in control file cataloged datafile copy datafile copy file name=/oracle/app/oradata/REDPANDA/datafile/o1_mf_sysaux_09l92bag_ . dbf RECID=3 STAMP=714157503 datafile 2 switched to datafile copy input datafile copy RECID=1 STAMP=714157503 file name=/oracle/app/oradata/REDPANDA/datafile/o1_mf_sysaux_09l92bag_ .dbf datafile 3 switched to datafile copy input datafile copy RECID=2 STAMP=714157503 file name=/oracle/app/oradata/REDPANDA/datafile/o1_mf_undotbs1_0al92bc s_. } executing Memory Script database opened Finished Duplicate Db at 20-MAR-10 11/13 .dbf ".dbf RECID=2 STAMP=714157503 cataloged datafile copy datafile copy file name=/oracle/app/oradata/REDPANDA/datafile/o1_mf_users_0bl92bd3_. } executing Memory Script executing command: SET NEWNAME renamed tempfile 1 to /oracle/app/oradata/REDPANDA/datafile/o1_mf_temp_%u_.Cloning A Database On The Same Server Using Rman Duplicate From Active Database "/oracle/app/oradata/REDPANDA/datafile/o1_mf_users_0bl92bd3_.

Cloning A Database On The Same Server Using Rman Duplicate From Active Database Remove The Old Pfile The duplicate database created an spfile that has the new controlfile names in it.dbf 12/13 . 2009. the old pfile. Connected to: Oracle Database 11g Enterprise Edition Release 11.ora Check The New Database ORACLE_SID=redpanda ORACLE_HOME=/oracle/app/product/11. Oracle. without controlfiles can be removed [oracle@lnx1 dbs]$ rm initredpanda.0 Production With the Partitioning. NAME ----------------------------------------------------------/ oracle/app/oradata/REDPANDA/datafile/o1_mf_system_08l92b7r_ .0. Data Mining and Real Application Testing options SQL> archive log list Database log mode Automatic archival Archive destination Oldest online log sequence Current log sequence No Archive Mode Disabled USE_DB_RECOVERY_FILE_DEST 1 1 SQL> select name from v$datafile.2.2.0/dbhome_1 [oracle@lnx1 dbs]$ sqlplus / as sysdba SQL*Plus: Release 11.0.1.2. OLAP.dbf / oracle/app/oradata/REDPANDA/datafile/o1_mf_sysaux_09l92bag_ .0 Production on Sat Mar 20 17:31:46 2010 Copyright (c) 1982. All rights reserved.1.

dbf SQL> show sga Total System Global Area Fixed Size Variable Size Database Buffers Redo Buffers 263639040 1335892 209718700 50331648 2252800 bytes bytes bytes bytes bytes 13/13 .dbf / oracle/app/oradata/REDPANDA/datafile/o1_mf_users_0bl92bd3_.Cloning A Database On The Same Server Using Rman Duplicate From Active Database / oracle/app/oradata/REDPANDA/datafile/o1_mf_undotbs1_0al92bc s_.

Sign up to vote on this title
UsefulNot useful