Duplicate a database using database backups from a backup location,
1. Create a dedicated listener configuraition of the auxiliary database in the listener.ora file present in $ORACLE_HOME/network/amdin directory.
[oracle@ol6-112-rac1 admin]$ cat listener.ora CV_DUPLICATE= (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.111)(PORT = 1524)) ) ) SID_LIST_CV_DUPLICATE= (SID_LIST= (SID_DESC= (ORACLE_HOME=/u01/app/orcl/oracle/product/11.2.0.3/db_1) (SID_NAME=orcldp1) ) )
2.Start the dedicated listener
lsnrctl start cv_duplicate
3.create a pfile for the duplicate database instance orcldp1 with only one entry db_name
[oracle@ol6-112-rac1 dbs]$ cat initorcldp1.ora db_name=orcldp
4.Create password file for the duplicate database instance orcldp1 in the $ORACLE_HOME/dbs directory
orapwd file=orapworcldp1.ora password=sys123 entries=10 force=y
5.Start the auxiliary database in nomount mode
[oracle@ol6-112-rac1 dbs]$ export ORACLE_SID=orcldp1 [oracle@ol6-112-rac1 dbs]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.3.0 Production on Sun Jun 15 16:37:14 2014 Copyright (c) 1982 , 2011, Oracle. All rights reserved. Connected to an idle instance. SQL> startup nomount ORACLE instance started. Total System Global Area 238034944 bytes Fixed Size 2227136 bytes Variable Size 180356160 bytes Database Buffers 50331648 bytes Redo Buffers 5120000 bytes SQL>
6.Write an entry for auxiliary database in $ORACLE_HOME/network/admin/tnsnames.ora file
orcldp1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ol6-112-rac1)(PORT = 1524)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcldp1) ) )
7.copy all the backups of the database, it includes controlfile,spfile,archivelogs,datafiles
[oracle@ol6-112-rac1 backup]$ pwd /u01/app/orcl/oracle/backup [oracle@ol6-112-rac1 backup]$ ls -l total 1945984 -rw-r----- 1 oracle oinstall 107080192 Jun 15 16:19 5hpatnmo_1_1 -rw-r----- 1 oracle oinstall 68341760 Jun 15 16:19 5ipatnmp_1_1 -rw-r----- 1 oracle oinstall 98089984 Jun 15 16:19 5jpatnmr_1_1 -rw-r----- 1 oracle oinstall 180637696 Jun 15 16:19 5kpatnmt_1_1 -rw-r----- 1 oracle oinstall 206191104 Jun 15 16:19 5lpatnmu_1_1 -rw-r----- 1 oracle oinstall 78526976 Jun 15 16:19 5mpatnoc_1_1 -rw-r----- 1 oracle oinstall 7284224 Jun 15 16:19 5npatnon_1_1 -rw-r----- 1 oracle oinstall 675307520 Jun 15 16:22 5opatnq7_1_1 -rw-r----- 1 oracle oinstall 535240704 Jun 15 16:22 5ppatnq7_1_1 -rw-r----- 1 oracle oinstall 16785408 Jun 15 16:20 5qpatnq8_1_1 -rw-r----- 1 oracle oinstall 165888 Jun 15 16:23 5rpatnvh_1_1 -rw-r----- 1 oracle oinstall 18907136 Jun 15 16:24 5tpato2e_1_1 -rw-r----- 1 oracle oinstall 98304 Jun 15 16:26 5vpato53_1_1
8.Script to perform duplicate database from backup location '/u01/app/orcl/oracle/backup'
duplicate database orcl to orcldp backup location '/u01/app/orcl/oracle/backup' device type disk spfile set instance_number='1' set control_files='+DATA','+DATA' set cluster_database='false' set log_file_name_convert='+DATA/orcl/','+DATA/orcldp/' set dispatchers='(PROTOCOL=TCP) (SERVICE=orcldpXDB)' set audit_file_dest='/u01/app/orcl/oracle/admin/orcldp/adump' db_file_name_convert='+DATA/orcl/','+DATA/orcldp/';
9.Output of script execution by connecting using rman
rman auxiliary="sys/sys123@orcldp1"
Recovery Manager: Release 11.2.0.3.0 - Production on Sun Jun 15 19:25:41 2014 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to auxiliary database: ORCLDP (not mounted) RMAN> RMAN> duplicate database orcl to orcldp 2> backup location '/u01/app/orcl/oracle/backup' 3> device type disk 4> spfile 5> set instance_number='1' 6> set control_files='+DATA','+DATA' 7> set cluster_database='false' 8> set log_file_name_convert='+DATA/orcl/','+DATA/orcldp/' 9> set dispatchers='(PROTOCOL=TCP) (SERVICE=orcldpXDB)' 10> set audit_file_dest='/u01/app/orcl/oracle/admin/orcldp/adump' 11> db_file_name_convert='+DATA/orcl/','+DATA/orcldp/'; Starting Duplicate Db at 15-jun-2014 19:25:48 contents of Memory Script: { restore clone spfile to '/u01/app/orcl/oracle/product/11.2.0.3/db_1/dbs/spfileorcldp1.ora' from '/u01/app/orcl/oracle/backup/5vpato53_1_1'; sql clone "alter system set spfile= ''/u01/app/orcl/oracle/product/11.2.0.3/db_1/dbs/spfileorcldp1.ora''"; } executing Memory Script Starting restore at 15-jun-2014 19:25:48 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=27 device type=DISK channel ORA_AUX_DISK_1: restoring spfile from AUTOBACKUP /u01/app/orcl/oracle/backup/5vpato53_1_1 channel ORA_AUX_DISK_1: SPFILE restore from AUTOBACKUP complete Finished restore at 15-jun-2014 19:25:50 sql statement: alter system set spfile= ''/u01/app/orcl/oracle/product/11.2.0.3/db_1/dbs/spfileorcldp1.ora'' contents of Memory Script: { sql clone "alter system set db_name = ''ORCLDP'' comment= ''duplicate'' scope=spfile"; sql clone "alter system set instance_number = 1 comment= '''' scope=spfile"; sql clone "alter system set control_files = ''+DATA'', ''+DATA'' comment= '''' scope=spfile"; sql clone "alter system set cluster_database = false comment= '''' scope=spfile"; sql clone "alter system set log_file_name_convert = ''+DATA/orcl/'', ''+DATA/orcldp/'' comment= '''' scope=spfile"; sql clone "alter system set dispatchers = ''(PROTOCOL=TCP) (SERVICE=orcldpXDB)'' comment= '''' scope=spfile"; sql clone "alter system set audit_file_dest = ''/u01/app/orcl/oracle/admin/orcldp/adump'' comment= '''' scope=spfile"; shutdown clone immediate; startup clone nomount; } executing Memory Script sql statement: alter system set db_name = ''ORCLDP'' comment= ''duplicate'' scope=spfile sql statement: alter system set instance_number = 1 comment= '''' scope=spfile sql statement: alter system set control_files = ''+DATA'', ''+DATA'' comment= '''' scope=spfile sql statement: alter system set cluster_database = false comment= '''' scope=spfile sql statement: alter system set log_file_name_convert = ''+DATA/orcl/'', ''+DATA/orcldp/'' comment= '''' scope=spfile sql statement: alter system set dispatchers = ''(PROTOCOL=TCP) (SERVICE=orcldpXDB)'' comment= '''' scope=spfile sql statement: alter system set audit_file_dest = ''/u01/app/orcl/oracle/admin/orcldp/adump'' comment= '''' scope=spfile Oracle instance shut down connected to auxiliary database (not started) Oracle instance started Total System Global Area 275578880 bytes Fixed Size 2227584 bytes Variable Size 113246848 bytes Database Buffers 155189248 bytes Redo Buffers 4915200 bytes contents of Memory Script: { sql clone "alter system set control_files = ''+DATA/orcldp/controlfile/current.324.850332389'', ''+DATA/orcldp/controlfile/current.308.850332389'' comment= ''Set by RMAN'' scope=spfile"; sql clone "alter system set db_name = ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfile"; sql clone "alter system set db_unique_name = ''ORCLDP'' comment= ''Modified by RMAN duplicate'' scope=spfile"; shutdown clone immediate; startup clone force nomount restore clone primary controlfile from '/u01/app/orcl/oracle/backup/5tpato2e_1_1'; alter clone database mount; } executing Memory Script sql statement: alter system set control_files = ''+DATA/orcldp/controlfile/current.324.850332389'', ''+DATA/orcldp/controlfile/current.308.850332389'' comment= ''Set by RMAN'' scope=spfile sql statement: alter system set db_name = ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfile sql statement: alter system set db_unique_name = ''ORCLDP'' comment= ''Modified by RMAN duplicate'' scope=spfile Oracle instance shut down Oracle instance started Total System Global Area 275578880 bytes Fixed Size 2227584 bytes Variable Size 117441152 bytes Database Buffers 150994944 bytes Redo Buffers 4915200 bytes Starting restore at 15-jun-2014 19:27:08 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=30 device type=DISK channel ORA_AUX_DISK_1: restoring control file channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:16 output file name=+DATA/orcldp/controlfile/current.324.850332389 output file name=+DATA/orcldp/controlfile/current.308.850332389 Finished restore at 15-jun-2014 19:27:24 database mounted released channel: ORA_AUX_DISK_1 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=30 device type=DISK allocated channel: ORA_AUX_DISK_2 channel ORA_AUX_DISK_2: SID=34 device type=DISK allocated channel: ORA_AUX_DISK_3 channel ORA_AUX_DISK_3: SID=35 device type=DISK allocated channel: ORA_AUX_DISK_4 channel ORA_AUX_DISK_4: SID=36 device type=DISK allocated channel: ORA_AUX_DISK_5 channel ORA_AUX_DISK_5: SID=37 device type=DISK RMAN-05529: WARNING: DB_FILE_NAME_CONVERT resulted in invalid ASM names; names changed to disk group only. contents of Memory Script: { set until scn 2775287; set newname for datafile 1 to "+DATA/orcldp/datafile/system.dbf"; set newname for datafile 2 to "+DATA/orcldp/datafile/sysaux.dbf"; set newname for datafile 3 to "+DATA/orcldp/datafile/undotbs1.dbf"; set newname for datafile 4 to "+DATA/orcldp/datafile/users.410.850308217"; set newname for datafile 5 to "+DATA/orcldp/datafile/undotbs2.411.850308181"; set newname for datafile 6 to "+DATA/orcldp/datafile/cattbs.472.850308137"; restore 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 Starting restore at 15-jun-2014 19:27:59 using channel ORA_AUX_DISK_1 using channel ORA_AUX_DISK_2 using channel ORA_AUX_DISK_3 using channel ORA_AUX_DISK_4 using channel ORA_AUX_DISK_5 channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00001 to +DATA/orcldp/datafile/system.dbf channel ORA_AUX_DISK_1: restoring datafile 00004 to +DATA/orcldp/datafile/users.410.850308217 channel ORA_AUX_DISK_1: reading from backup piece /u01/app/orcl/oracle/backup/5opatnq7_1_1 channel ORA_AUX_DISK_2: starting datafile backup set restore channel ORA_AUX_DISK_2: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_2: restoring datafile 00003 to +DATA/orcldp/datafile/undotbs1.dbf channel ORA_AUX_DISK_2: restoring datafile 00006 to +DATA/orcldp/datafile/cattbs.472.850308137 channel ORA_AUX_DISK_2: reading from backup piece /u01/app/orcl/oracle/backup/5qpatnq8_1_1 channel ORA_AUX_DISK_3: starting datafile backup set restore channel ORA_AUX_DISK_3: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_3: restoring datafile 00002 to +DATA/orcldp/datafile/sysaux.dbf channel ORA_AUX_DISK_3: restoring datafile 00005 to +DATA/orcldp/datafile/undotbs2.411.850308181 channel ORA_AUX_DISK_3: reading from backup piece /u01/app/orcl/oracle/backup/5ppatnq7_1_1 channel ORA_AUX_DISK_2: piece handle=/u01/app/orcl/oracle/backup/5qpatnq8_1_1 tag=TAG20140615T162007 channel ORA_AUX_DISK_2: restored backup piece 1 channel ORA_AUX_DISK_2: restore complete, elapsed time: 00:01:05 channel ORA_AUX_DISK_3: piece handle=/u01/app/orcl/oracle/backup/5ppatnq7_1_1 tag=TAG20140615T162007 channel ORA_AUX_DISK_3: restored backup piece 1 channel ORA_AUX_DISK_3: restore complete, elapsed time: 00:08:55 channel ORA_AUX_DISK_1: piece handle=/u01/app/orcl/oracle/backup/5opatnq7_1_1 tag=TAG20140615T162007 channel ORA_AUX_DISK_1: restored backup piece 1 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:09:55 Finished restore at 15-jun-2014 19:37:57 contents of Memory Script: { switch clone datafile all; } executing Memory Script datafile 1 switched to datafile copy input datafile copy RECID=7 STAMP=850333099 file name=+DATA/orcldp/datafile/system.dbf datafile 2 switched to datafile copy input datafile copy RECID=8 STAMP=850333103 file name=+DATA/orcldp/datafile/sysaux.dbf datafile 3 switched to datafile copy input datafile copy RECID=9 STAMP=850333104 file name=+DATA/orcldp/datafile/undotbs1.dbf datafile 4 switched to datafile copy input datafile copy RECID=10 STAMP=850333105 file name=+DATA/orcldp/datafile/users.416.850332483 datafile 5 switched to datafile copy input datafile copy RECID=11 STAMP=850333106 file name=+DATA/orcldp/datafile/undotbs2.410.850332483 datafile 6 switched to datafile copy input datafile copy RECID=12 STAMP=850333107 file name=+DATA/orcldp/datafile/cattbs.417.850332483 contents of Memory Script: { set until scn 2775287; recover clone database delete archivelog ; } executing Memory Script executing command: SET until clause Starting recover at 15-jun-2014 19:38:34 using channel ORA_AUX_DISK_1 using channel ORA_AUX_DISK_2 using channel ORA_AUX_DISK_3 using channel ORA_AUX_DISK_4 using channel ORA_AUX_DISK_5 starting media recovery channel ORA_AUX_DISK_1: starting archived log restore to default destination channel ORA_AUX_DISK_1: restoring archived log archived log thread=1 sequence=56 channel ORA_AUX_DISK_1: reading from backup piece /u01/app/orcl/oracle/backup/5rpatnvh_1_1 channel ORA_AUX_DISK_1: piece handle=/u01/app/orcl/oracle/backup/5rpatnvh_1_1 tag=TAG20140615T162313 channel ORA_AUX_DISK_1: restored backup piece 1 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 archived log file name=+DATA/orcldp/archivelog/2014_06_15/thread_1_seq_56.411.850333121 thread=1 sequence=56 channel clone_default: deleting archived log(s) archived log file name=+DATA/orcldp/archivelog/2014_06_15/thread_1_seq_56.411.850333121 RECID=1 STAMP=850333122 media recovery complete, elapsed time: 00:00:15 Finished recover at 15-jun-2014 19:38:57 Oracle instance started Total System Global Area 275578880 bytes Fixed Size 2227584 bytes Variable Size 121635456 bytes Database Buffers 146800640 bytes Redo Buffers 4915200 bytes contents of Memory Script: { sql clone "alter system set db_name = ''ORCLDP'' 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 Memory Script sql statement: alter system set db_name = ''ORCLDP'' comment= ''Reset to original value by RMAN'' scope=spfile sql statement: alter system reset db_unique_name scope=spfile Oracle instance shut down connected to auxiliary database (not started) Oracle instance started Total System Global Area 275578880 bytes Fixed Size 2227584 bytes Variable Size 121635456 bytes Database Buffers 146800640 bytes Redo Buffers 4915200 bytes sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCLDP" RESETLOGS ARCHIVELOG MAXLOGFILES 192 MAXLOGMEMBERS 3 MAXDATAFILES 1024 MAXINSTANCES 32 MAXLOGHISTORY 292 LOGFILE GROUP 5 ( '+data', '+data' ) SIZE 100 M REUSE, GROUP 6 ( '+data', '+data' ) SIZE 100 M REUSE DATAFILE '+DATA/orcldp/datafile/system.dbf' CHARACTER SET AL32UTF8 sql statement: ALTER DATABASE ADD LOGFILE INSTANCE 'i2' GROUP 7 ( '+data', '+data' ) SIZE 100 M REUSE, GROUP 8 ( '+data', '+data' ) SIZE 100 M REUSE contents of Memory Script: { set newname for tempfile 2 to "+data"; switch clone tempfile all; catalog clone datafilecopy "+DATA/orcldp/datafile/sysaux.dbf", "+DATA/orcldp/datafile/undotbs1.dbf", "+DATA/orcldp/datafile/users.416.850332483", "+DATA/orcldp/datafile/undotbs2.410.850332483", "+DATA/orcldp/datafile/cattbs.417.850332483"; switch clone datafile all; } executing Memory Script executing command: SET NEWNAME renamed tempfile 2 to +data in control file cataloged datafile copy datafile copy file name=+DATA/orcldp/datafile/sysaux.dbf RECID=1 STAMP=850333224 cataloged datafile copy datafile copy file name=+DATA/orcldp/datafile/undotbs1.dbf RECID=2 STAMP=850333224 cataloged datafile copy datafile copy file name=+DATA/orcldp/datafile/users.416.850332483 RECID=3 STAMP=850333224 cataloged datafile copy datafile copy file name=+DATA/orcldp/datafile/undotbs2.410.850332483 RECID=4 STAMP=850333225 cataloged datafile copy datafile copy file name=+DATA/orcldp/datafile/cattbs.417.850332483 RECID=5 STAMP=850333225 datafile 2 switched to datafile copy input datafile copy RECID=1 STAMP=850333224 file name=+DATA/orcldp/datafile/sysaux.dbf datafile 3 switched to datafile copy input datafile copy RECID=2 STAMP=850333224 file name=+DATA/orcldp/datafile/undotbs1.dbf datafile 4 switched to datafile copy input datafile copy RECID=3 STAMP=850333224 file name=+DATA/orcldp/datafile/users.416.850332483 datafile 5 switched to datafile copy input datafile copy RECID=4 STAMP=850333225 file name=+DATA/orcldp/datafile/undotbs2.410.850332483 datafile 6 switched to datafile copy input datafile copy RECID=5 STAMP=850333225 file name=+DATA/orcldp/datafile/cattbs.417.850332483 contents of Memory Script: { Alter clone database open resetlogs; } executing Memory Script database opened Finished Duplicate Db at 15-jun-2014 19:42:35 RMAN> RMAN> RMAN> **end-of-file** RMAN> Recovery Manager complete.
No comments:
Post a Comment