Friday, May 24, 2013

Rman Targetless Duplication Of Oacle Database 11gr2

Since Oracle 11gr2 you can now duplicate an Oracle database without the need to connect to the target database. This is convenient option when the target database is not availiable for duplication.
You must have the dbid of the target database.

You can get that to logon to the database where the rman catalog is in a run th following sql script

SQL>select a.db_name,b.db_id
         from dbinc a, db b
        where a.db_name = 'ODBA3'
         and a.db_key = b.db_key;
DB_NAME                       DB_ID
------------------------ ----------
ODBA3                     431532821

and here is the commando to start the duplicate

RMAN>connect catalog rmn_owner/password@catdb;
RMAN>connect auxiliary /;
RMAN>set dbid 431532821;
RMAN>run
{
set until time "to_date('22-May-2013 08:00:00','dd-mon-yyyy hh24:mi:ss')";
allocate auxiliary channel ch1  TYPE 'SBT_TAPE' PARMS  'BLKSIZE=1048576, ENV=(TDPO_OPTFILE=/u01/app/oracle/admin/tdp/dat/ODBA3_tdpo.opt)';
duplicate database 'ODBA3' to 'ODBA6';
}

connected to recovery catalog database
connected to auxiliary database: ODBA6 (not mounted)
executing command: SET DBID
executing command: SET until clause
allocated channel: ch1
channel ch1: SID=2 device type=SBT_TAPE
channel ch1: Data Protection for Oracle: version 5.4.1.0
Starting Duplicate Db at 23-05-2013:18:24:18
contents of Memory Script:
{
   set until scn  17458231;
   sql clone "alter system set  db_name =
 ''ODBA3'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone primary controlfile;
   alter clone database mount;
}
executing Memory Script
executing command: SET until clause
sql statement: alter system set  db_name =  ''ODBA3'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area    1603411968 bytes
Fixed Size                     2228784 bytes
Variable Size               1358958032 bytes
Database Buffers             234881024 bytes
Redo Buffers                   7344128 bytes
allocated channel: ch1
channel ch1: SID=872 device type=SBT_TAPE
channel ch1: Data Protection for Oracle: version 5.4.1.0
Starting restore at 23-05-2013:18:24:42
channel ch1: starting datafile backup set restore
channel ch1: restoring control file
channel ch1: reading from backup piece c-431532821-20130522-08
channel ch1: piece handle=c-431532821-20130522-08 tag=TAG20130522T072120
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:03
output file name=+DGO1/odba6_01/control01.ctl
output file name=+DGOFRA1/odba6_01/control02.ctl
Finished restore at 23-05-2013:18:24:46
database mounted
contents of Memory Script:
{
   set until scn  17458231;
   sql clone 'alter database flashback off';
   set newname for clone datafile  1 to new;
   set newname for clone datafile  2 to new;
   set newname for clone datafile  3 to new;
   set newname for clone datafile  4 to new;
   set newname for clone datafile  5 to new;
   set newname for clone datafile  6 to new;
   restore
   clone database
   ;
}
executing Memory Script
executing command: SET until clause
sql statement: alter database flashback off
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 23-05-2013:18:24:56
channel ch1: starting datafile backup set restore
channel ch1: specifying datafile(s) to restore from backup set
channel ch1: restoring datafile 00001 to +DGO1
channel ch1: restoring datafile 00002 to +DGO1
channel ch1: restoring datafile 00003 to +DGO1
channel ch1: restoring datafile 00004 to +DGO1
channel ch1: restoring datafile 00005 to +DGO1
channel ch1: restoring datafile 00006 to +DGO1
channel ch1: reading from backup piece beo9qq2o_1_1
channel ch1: piece handle=beo9qq2o_1_1 tag=TAG20130517T014350
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:02:45
Finished restore at 23-05-2013:18:27:56
contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=175 STAMP=816200876 file name=+DGO1/odba6_01/datafile/system.589.816200763
datafile 2 switched to datafile copy
input datafile copy RECID=176 STAMP=816200876 file name=+DGO1/odba6_01/datafile/sysaux.590.816200761
datafile 3 switched to datafile copy
input datafile copy RECID=177 STAMP=816200876 file name=+DGO1/odba6_01/datafile/undotbs1.592.816200757
datafile 4 switched to datafile copy
input datafile copy RECID=178 STAMP=816200876 file name=+DGO1/odba6_01/datafile/tools.842.816200763
datafile 5 switched to datafile copy
input datafile copy RECID=179 STAMP=816200876 file name=+DGO1/odba6_01/datafile/undotbs2.591.816200759
datafile 6 switched to datafile copy
input datafile copy RECID=180 STAMP=816200876 file name=+DGO1/odba6_01/datafile/users.847.816200763
contents of Memory Script:
{
   set until time  "to_date('MAY 22 2013 08:00:00', 'MON DD YYYY HH24:MI:SS')";
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script
executing command: SET until clause
Starting recover at 23-05-2013:18:27:57
channel ch1: starting incremental datafile backup set restore
channel ch1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: +DGO1/odba6_01/datafile/system.589.816200763
destination for restore of datafile 00002: +DGO1/odba6_01/datafile/sysaux.590.816200761
destination for restore of datafile 00003: +DGO1/odba6_01/datafile/undotbs1.592.816200757
destination for restore of datafile 00004: +DGO1/odba6_01/datafile/tools.842.816200763
destination for restore of datafile 00005: +DGO1/odba6_01/datafile/undotbs2.591.816200759
destination for restore of datafile 00006: +DGO1/odba6_01/datafile/users.847.816200763
channel ch1: reading from backup piece cjo9tdom_1_1
channel ch1: piece handle=cjo9tdom_1_1 tag=TAG20130518T013203
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:07
channel ch1: starting incremental datafile backup set restore
channel ch1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: +DGO1/odba6_01/datafile/system.589.816200763
destination for restore of datafile 00002: +DGO1/odba6_01/datafile/sysaux.590.816200761
destination for restore of datafile 00003: +DGO1/odba6_01/datafile/undotbs1.592.816200757
destination for restore of datafile 00004: +DGO1/odba6_01/datafile/tools.842.816200763
destination for restore of datafile 00005: +DGO1/odba6_01/datafile/undotbs2.591.816200759
destination for restore of datafile 00006: +DGO1/odba6_01/datafile/users.847.816200763
channel ch1: reading from backup piece e7oa024o_1_1
channel ch1: piece handle=e7oa024o_1_1 tag=TAG20130519T013205
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:16
channel ch1: starting incremental datafile backup set restore
channel ch1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: +DGO1/odba6_01/datafile/system.589.816200763
destination for restore of datafile 00002: +DGO1/odba6_01/datafile/sysaux.590.816200761
destination for restore of datafile 00003: +DGO1/odba6_01/datafile/undotbs1.592.816200757
destination for restore of datafile 00004: +DGO1/odba6_01/datafile/tools.842.816200763
destination for restore of datafile 00005: +DGO1/odba6_01/datafile/undotbs2.591.816200759
destination for restore of datafile 00006: +DGO1/odba6_01/datafile/users.847.816200763
channel ch1: reading from backup piece froa2mi2_1_1
channel ch1: piece handle=froa2mi2_1_1 tag=TAG20130520T013247
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:07
channel ch1: starting incremental datafile backup set restore
channel ch1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: +DGO1/odba6_01/datafile/system.589.816200763
destination for restore of datafile 00002: +DGO1/odba6_01/datafile/sysaux.590.816200761
destination for restore of datafile 00003: +DGO1/odba6_01/datafile/undotbs1.592.816200757
destination for restore of datafile 00004: +DGO1/odba6_01/datafile/tools.842.816200763
destination for restore of datafile 00005: +DGO1/odba6_01/datafile/undotbs2.591.816200759
destination for restore of datafile 00006: +DGO1/odba6_01/datafile/users.847.816200763
channel ch1: reading from backup piece hfoa5ati_1_1
channel ch1: piece handle=hfoa5ati_1_1 tag=TAG20130521T013231
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:15
channel ch1: starting incremental datafile backup set restore
channel ch1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: +DGO1/odba6_01/datafile/system.589.816200763
destination for restore of datafile 00002: +DGO1/odba6_01/datafile/sysaux.590.816200761
destination for restore of datafile 00003: +DGO1/odba6_01/datafile/undotbs1.592.816200757
destination for restore of datafile 00004: +DGO1/odba6_01/datafile/tools.842.816200763
destination for restore of datafile 00005: +DGO1/odba6_01/datafile/undotbs2.591.816200759
destination for restore of datafile 00006: +DGO1/odba6_01/datafile/users.847.816200763
channel ch1: reading from backup piece j3oa7v96_1_1
channel ch1: piece handle=j3oa7v96_1_1 tag=TAG20130522T013219
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:15
starting media recovery
channel ch1: starting archived log restore to default destination
channel ch1: restoring archived log
archived log thread=2 sequence=642
channel ch1: restoring archived log
archived log thread=1 sequence=643
channel ch1: reading from backup piece j4oa7va8_1_1
channel ch1: piece handle=j4oa7va8_1_1 tag=TAG20130522T013254
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:01
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_1_seq_643.2924.816200949 thread=1 sequence=643
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_2_seq_642.1165.816200949 thread=2 sequence=642
channel clone_default: deleting archived log(s)
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_1_seq_643.2924.816200949 RECID=2938 STAMP=816200948
channel ch1: starting archived log restore to default destination
channel ch1: restoring archived log
archived log thread=1 sequence=644
channel ch1: restoring archived log
archived log thread=2 sequence=643
channel ch1: reading from backup piece j6oa824v_1_1
channel ch1: piece handle=j6oa824v_1_1 tag=TAG20130522T022117
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:01
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_1_seq_644.2924.816200951 thread=1 sequence=644
channel clone_default: deleting archived log(s)
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_2_seq_642.1165.816200949 RECID=2939 STAMP=816200948
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_2_seq_643.383.816200951 thread=2 sequence=643
channel clone_default: deleting archived log(s)
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_1_seq_644.2924.816200951 RECID=2941 STAMP=816200950
channel ch1: starting archived log restore to default destination
channel ch1: restoring archived log
archived log thread=1 sequence=645
channel ch1: restoring archived log
archived log thread=2 sequence=644
channel ch1: reading from backup piece j8oa85lb_1_1
channel ch1: piece handle=j8oa85lb_1_1 tag=TAG20130522T032112
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:01
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_1_seq_645.2924.816200953 thread=1 sequence=645
channel clone_default: deleting archived log(s)
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_2_seq_643.383.816200951 RECID=2940 STAMP=816200950
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_2_seq_644.1165.816200953 thread=2 sequence=644
channel clone_default: deleting archived log(s)
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_1_seq_645.2924.816200953 RECID=2943 STAMP=816200952
channel ch1: starting archived log restore to default destination
channel ch1: restoring archived log
archived log thread=1 sequence=646
channel ch1: restoring archived log
archived log thread=2 sequence=645
channel ch1: reading from backup piece jaoa895r_1_1
channel ch1: piece handle=jaoa895r_1_1 tag=TAG20130522T042113
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:01
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_1_seq_646.2924.816200955 thread=1 sequence=646
channel clone_default: deleting archived log(s)
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_2_seq_644.1165.816200953 RECID=2942 STAMP=816200952
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_2_seq_645.383.816200955 thread=2 sequence=645
channel clone_default: deleting archived log(s)
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_1_seq_646.2924.816200955 RECID=2945 STAMP=816200954
channel ch1: starting archived log restore to default destination
channel ch1: restoring archived log
archived log thread=1 sequence=647
channel ch1: restoring archived log
archived log thread=2 sequence=646
channel ch1: reading from backup piece jcoa8cmc_1_1
channel ch1: piece handle=jcoa8cmc_1_1 tag=TAG20130522T052114
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:01
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_1_seq_647.2924.816200957 thread=1 sequence=647
channel clone_default: deleting archived log(s)
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_2_seq_645.383.816200955 RECID=2944 STAMP=816200954
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_2_seq_646.1165.816200957 thread=2 sequence=646
channel clone_default: deleting archived log(s)
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_2_seq_646.1165.816200957 RECID=2946 STAMP=816200956
channel ch1: starting archived log restore to default destination
channel ch1: restoring archived log
archived log thread=2 sequence=647
channel ch1: restoring archived log
archived log thread=1 sequence=648
channel ch1: reading from backup piece jeoa8g70_1_1
channel ch1: piece handle=jeoa8g70_1_1 tag=TAG20130522T062118
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:01
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_2_seq_647.383.816200959 thread=2 sequence=647
channel clone_default: deleting archived log(s)
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_1_seq_647.2924.816200957 RECID=2947 STAMP=816200956
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_1_seq_648.1165.816200959 thread=1 sequence=648
channel clone_default: deleting archived log(s)
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_1_seq_648.1165.816200959 RECID=2949 STAMP=816200958
channel ch1: starting archived log restore to default destination
channel ch1: restoring archived log
archived log thread=1 sequence=649
channel ch1: restoring archived log
archived log thread=2 sequence=648
channel ch1: reading from backup piece jgoa8jnc_1_1
channel ch1: piece handle=jgoa8jnc_1_1 tag=TAG20130522T072113
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:01
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_1_seq_649.1165.816200961 thread=1 sequence=649
channel clone_default: deleting archived log(s)
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_2_seq_647.383.816200959 RECID=2948 STAMP=816200958
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_2_seq_648.2924.816200961 thread=2 sequence=648
channel clone_default: deleting archived log(s)
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_2_seq_648.2924.816200961 RECID=2950 STAMP=816200960
channel ch1: starting archived log restore to default destination
channel ch1: restoring archived log
archived log thread=2 sequence=649
channel ch1: restoring archived log
archived log thread=1 sequence=650
channel ch1: reading from backup piece jioa8n7u_1_1
channel ch1: piece handle=jioa8n7u_1_1 tag=TAG20130522T082116
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:01
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_2_seq_649.383.816200961 thread=2 sequence=649
channel clone_default: deleting archived log(s)
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_1_seq_649.1165.816200961 RECID=2951 STAMP=816200960
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_1_seq_650.2924.816200963 thread=1 sequence=650
channel clone_default: deleting archived log(s)
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_1_seq_650.2924.816200963 RECID=2953 STAMP=816200962
channel clone_default: deleting archived log(s)
archived log file name=+DGOFRA1/odba6_01/archivelog/2013_05_23/thread_2_seq_649.383.816200961 RECID=2952 STAMP=816200961
media recovery complete, elapsed time: 00:00:01
Finished recover at 23-05-2013:18:29:23
Oracle instance started
Total System Global Area    1603411968 bytes
Fixed Size                     2228784 bytes
Variable Size               1358958032 bytes
Database Buffers             234881024 bytes
Redo Buffers                   7344128 bytes
contents of Memory Script:
{
   sql clone "alter system set  db_name =
 ''ODBA6'' comment=
 ''Reset to original value by RMAN'' scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script
sql statement: alter system set  db_name =  ''ODBA6'' comment= ''Reset to original value by RMAN'' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area    1603411968 bytes
Fixed Size                     2228784 bytes
Variable Size               1358958032 bytes
Database Buffers             234881024 bytes
Redo Buffers                   7344128 bytes
allocated channel: ch1
channel ch1: SID=872 device type=SBT_TAPE
channel ch1: Data Protection for Oracle: version 5.4.1.0
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ODBA6" RESETLOGS ARCHIVELOG
  MAXLOGFILES    192
  MAXLOGMEMBERS      3
  MAXDATAFILES     1024
  MAXINSTANCES    32
  MAXLOGHISTORY     1232
 LOGFILE
  GROUP   1  SIZE 256 M ,
  GROUP   2  SIZE 256 M ,
  GROUP   3  SIZE 256 M
 DATAFILE
  '+DGO1/odba6_01/datafile/system.589.816200763'
 CHARACTER SET AL32UTF8
sql statement: ALTER DATABASE ADD LOGFILE

  INSTANCE 'i2'
  GROUP   4  SIZE 256 M ,
  GROUP   5  SIZE 256 M ,
  GROUP   6  SIZE 256 M
contents of Memory Script:
{
   set newname for clone tempfile  1 to new;
   switch clone tempfile all;
   catalog clone datafilecopy  "+DGO1/odba6_01/datafile/sysaux.590.816200761",
 "+DGO1/odba6_01/datafile/undotbs1.592.816200757",
 "+DGO1/odba6_01/datafile/tools.842.816200763",
 "+DGO1/odba6_01/datafile/undotbs2.591.816200759",
 "+DGO1/odba6_01/datafile/users.847.816200763";
   switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to +DGO1 in control file
cataloged datafile copy
datafile copy file name=+DGO1/odba6_01/datafile/sysaux.590.816200761 RECID=1 STAMP=816200999
cataloged datafile copy
datafile copy file name=+DGO1/odba6_01/datafile/undotbs1.592.816200757 RECID=2 STAMP=816200999
cataloged datafile copy
datafile copy file name=+DGO1/odba6_01/datafile/tools.842.816200763 RECID=3 STAMP=816200999
cataloged datafile copy
datafile copy file name=+DGO1/odba6_01/datafile/undotbs2.591.816200759 RECID=4 STAMP=816200999
cataloged datafile copy
datafile copy file name=+DGO1/odba6_01/datafile/users.847.816200763 RECID=5 STAMP=816200999
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=816200999 file name=+DGO1/odba6_01/datafile/sysaux.590.816200761
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=816200999 file name=+DGO1/odba6_01/datafile/undotbs1.592.816200757
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=816200999 file name=+DGO1/odba6_01/datafile/tools.842.816200763
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=816200999 file name=+DGO1/odba6_01/datafile/undotbs2.591.816200759
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=816200999 file name=+DGO1/odba6_01/datafile/users.847.816200763
Reenabling controlfile options for auxiliary database
Executing: alter database force logging
Executing: alter database enable block change tracking
contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script
database opened
Executing: alter database flashback on
Finished Duplicate Db at 23-05-2013:18:30:19
released channel: ch1
Recovery Manager complete.

1 comment:

  1. As widely accepted and adopted by enterprises worldwide, Oracle E-Business R12 Upgrade has been acknowledged as the most stable and reliable version for enterprise applications. Nevertheless, as with any other major changes to business applications, the upgrade to R12 must be planned and carried out carefully to make sure a seamless transition and guarantee business continuity. Get more info on R12 Upgrade

    ReplyDelete