RMAN DUPLICATION 12C EXPLAINED IN ORACLE

Let us observe keenly on the step by step execution of rman duplication for database cloning.

Step 1: Connected the database to target and auxiliary

Step 2: Channels allocated from storage device (disk)

[oracle@orcl19x ~]$ rman target sys/password@orcl12x auxiliary sys/password@orcl19x

Recovery Manager: Release 12.1.0.2.0 - Production on Fri Dec 25 19:33:39 2020

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL12X (DBID=1955551678)
connected to auxiliary database: ORCL19X (not mounted)

RMAN> run
{
allocate channel ch1 type disk;
allocate channel ch2 type disk;
allocate auxiliary channel ch3 type disk;
allocate auxiliary channel ch4 type disk;
allocate auxiliary channel ch5 type disk;
duplicate database to orcl19x from active database nofilenamecheck ;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
release channel ch5;
}2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14>

using target database control file instead of recovery catalog
allocated channel: ch1
channel ch1: SID=34 device type=DISK

allocated channel: ch2
channel ch2: SID=46 device type=DISK

allocated channel: ch3
channel ch3: SID=13 device type=DISK

allocated channel: ch4
channel ch4: SID=173 device type=DISK

allocated channel: ch5
channel ch5: SID=14 device type=DISK

Step 3: We can observe a script with set of SQL commands.

  • First the db name and db unique name is set as source name.
  • Post that a clone instance is bounced
  • Controlfile restore is performed with the service name of source and database is also mounted.
Starting Duplicate Db at 25-DEC-20
current log archived

contents of Memory Script:
{
   sql clone "alter system set  db_name =
 ''ORCL12X'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name =
 ''ORCL19X'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone from service  'orcl12x' primary controlfile;
   alter clone database mount;
}
executing Memory Script

Script is executed for clone as simple as that!

sql statement: alter system set  db_name =  ''ORCL12X'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set  db_unique_name =  ''ORCL19X'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area     234881024 bytes

Fixed Size                     2922904 bytes
Variable Size                176162408 bytes
Database Buffers              50331648 bytes
Redo Buffers                   5464064 bytes
allocated channel: ch3
channel ch3: SID=12 device type=DISK
allocated channel: ch4
channel ch4: SID=173 device type=DISK
allocated channel: ch5
channel ch5: SID=14 device type=DISK

Starting restore at 25-DEC-20

channel ch3: starting datafile backup set restore
channel ch3: using network backup set from service orcl12x
channel ch3: restoring control file
channel ch3: restore complete, elapsed time: 00:00:02
output file name=/apps01/product/12.1.0/dbhome_1/dbs/cntrlorcl19x.dbf
Finished restore at 25-DEC-20

database mounted

After the database is mounted, again a new script is prepared automatically by RMAN. This script contains,

  • For all the datafiles, set newname command is generated and post that clone database is restored from service. Also a log switch is performed.
contents of Memory Script:
{
   set newname for datafile  1 to
 "/apps01/oradata/orcl19xsystem01.dbf";
   set newname for datafile  2 to
 "//apps01/oradata/orcl19x/EXAMPLE6345.dbf";
   set newname for datafile  3 to
 "/apps01/oradata/orcl19xsysaux01.dbf";
   set newname for datafile  4 to
 "/apps01/oradata/orcl19xundotbs01.dbf";
   set newname for datafile  5 to
 "/apps01/oradata/orcl19xexample01.dbf";
   set newname for datafile  6 to
 "/apps01/oradata/orcl19xusers01.dbf";
   set newname for datafile  7 to
 "//apps01/oradata/orcl19x/EXAMPLE12625.dbf";
   set newname for datafile  8 to
 "//apps01/oradata/orcl19x/SYSAUX18237.dbf";
   set newname for datafile  9 to
 "//apps01/oradata/orcl19x/SYSTEM9302.dbf";
   set newname for datafile  10 to
 "//apps01/oradata/orcl19x/EXAMPLE7187.dbf";
   restore
   from service  'orcl12x'   clone database
   ;
   sql 'alter system archive log current';
}

The clone database restore script is executed

executing Memory Script

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 25-DEC-20

channel ch3: starting datafile backup set restore
channel ch3: using network backup set from service orcl12x
channel ch3: specifying datafile(s) to restore from backup set
channel ch3: restoring datafile 00001 to /apps01/oradata/orcl19xsystem01.dbf
channel ch4: starting datafile backup set restore
channel ch4: using network backup set from service orcl12x
channel ch4: specifying datafile(s) to restore from backup set
channel ch4: restoring datafile 00002 to //apps01/oradata/orcl19x/EXAMPLE6345.dbf
channel ch5: starting datafile backup set restore
channel ch5: using network backup set from service orcl12x
channel ch5: specifying datafile(s) to restore from backup set
channel ch5: restoring datafile 00003 to /apps01/oradata/orcl19xsysaux01.dbf
channel ch4: restore complete, elapsed time: 00:00:01
channel ch4: starting datafile backup set restore
channel ch4: using network backup set from service orcl12x
channel ch4: specifying datafile(s) to restore from backup set
channel ch4: restoring datafile 00004 to /apps01/oradata/orcl19xundotbs01.dbf
channel ch4: restore complete, elapsed time: 00:00:08
channel ch4: starting datafile backup set restore
channel ch4: using network backup set from service orcl12x
channel ch4: specifying datafile(s) to restore from backup set
channel ch4: restoring datafile 00005 to /apps01/oradata/orcl19xexample01.dbf
channel ch3: restore complete, elapsed time: 00:01:04
channel ch3: starting datafile backup set restore
channel ch3: using network backup set from service orcl12x
channel ch3: specifying datafile(s) to restore from backup set
channel ch3: restoring datafile 00006 to /apps01/oradata/orcl19xusers01.dbf
channel ch5: restore complete, elapsed time: 00:01:08
channel ch5: starting datafile backup set restore
channel ch5: using network backup set from service orcl12x
channel ch5: specifying datafile(s) to restore from backup set
channel ch5: restoring datafile 00007 to //apps01/oradata/orcl19x/EXAMPLE12625.dbf
channel ch5: restore complete, elapsed time: 00:00:01
channel ch5: starting datafile backup set restore
channel ch5: using network backup set from service orcl12x
channel ch5: specifying datafile(s) to restore from backup set
channel ch5: restoring datafile 00008 to //apps01/oradata/orcl19x/SYSAUX18237.dbf
channel ch5: restore complete, elapsed time: 00:00:01
channel ch5: starting datafile backup set restore
channel ch5: using network backup set from service orcl12x
channel ch5: specifying datafile(s) to restore from backup set
channel ch5: restoring datafile 00009 to //apps01/oradata/orcl19x/SYSTEM9302.dbf
channel ch5: restore complete, elapsed time: 00:00:01
channel ch5: starting datafile backup set restore
channel ch5: using network backup set from service orcl12x
channel ch5: specifying datafile(s) to restore from backup set
channel ch5: restoring datafile 00010 to //apps01/oradata/orcl19x/EXAMPLE7187.dbf
channel ch5: restore complete, elapsed time: 00:00:02
channel ch4: restore complete, elapsed time: 00:01:38
channel ch3: restore complete, elapsed time: 00:00:53
Finished restore at 25-DEC-20

Now its time to restore the archivelogs and switch the datafile name of clone database

  • Restore clone database from scn using service
  • Switch the clone datafiles
sql statement: alter system archive log current
current log archived

contents of Memory Script:
{
   restore clone force from service  'orcl12x'
           archivelog from scn  9397504;
   switch clone datafile all;
}
executing Memory Script

Starting restore at 25-DEC-20

channel ch3: starting archived log restore to default destination
channel ch3: using network backup set from service orcl12x
channel ch3: restoring archived log
archived log thread=1 sequence=94
channel ch4: starting archived log restore to default destination
channel ch4: using network backup set from service orcl12x
channel ch4: restoring archived log
archived log thread=1 sequence=95
channel ch3: restore complete, elapsed time: 00:00:01
channel ch4: restore complete, elapsed time: 00:00:01
Finished restore at 25-DEC-20

Datafile location is switched automatically or to say automagically 😉

datafile 1 switched to datafile copy
input datafile copy RECID=11 STAMP=1060112186 file name=/apps01/oradata/orcl19xsystem01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=12 STAMP=1060112186 file name=/apps01/oradata/orcl19x/EXAMPLE6345.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=13 STAMP=1060112186 file name=/apps01/oradata/orcl19xsysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=14 STAMP=1060112186 file name=/apps01/oradata/orcl19xundotbs01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=15 STAMP=1060112186 file name=/apps01/oradata/orcl19xexample01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=16 STAMP=1060112186 file name=/apps01/oradata/orcl19xusers01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=17 STAMP=1060112187 file name=/apps01/oradata/orcl19x/EXAMPLE12625.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=18 STAMP=1060112187 file name=/apps01/oradata/orcl19x/SYSAUX18237.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=19 STAMP=1060112187 file name=/apps01/oradata/orcl19x/SYSTEM9302.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=20 STAMP=1060112187 file name=/apps01/oradata/orcl19x/EXAMPLE7187.dbf

Now database recovery is started for clone of database

  • set until clause is used with scn number
  • recover the database and delete the cloned archives
contents of Memory Script:
{
   set until scn  9397656;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 25-DEC-20

Media recovery starts

starting media recovery

archived log for thread 1 with sequence 94 is already on disk as file /apps01/product/12.1.0/dbhome_1/dbs/arch1_94_1058323394.dbf
archived log for thread 1 with sequence 95 is already on disk as file /apps01/product/12.1.0/dbhome_1/dbs/arch1_95_1058323394.dbf
archived log file name=/apps01/product/12.1.0/dbhome_1/dbs/arch1_94_1058323394.dbf thread=1 sequence=94
archived log file name=/apps01/product/12.1.0/dbhome_1/dbs/arch1_95_1058323394.dbf thread=1 sequence=95
media recovery complete, elapsed time: 00:00:00
Finished recover at 25-DEC-20

Now,

  • Controlfile is created with reuse option and database name is changed in controlfile header
  • Datafile clone is cataloged
  • tempfiles are renamed
  • Database is opened with resetlogs
Oracle instance started

Total System Global Area     234881024 bytes

Fixed Size                     2922904 bytes
Variable Size                176162408 bytes
Database Buffers              50331648 bytes
Redo Buffers                   5464064 bytes

contents of Memory Script:
{
   sql clone "alter system set  db_name =
 ''ORCL19X'' comment=
 ''Reset to original value by RMAN'' scope=spfile";
   sql clone "alter system reset  db_unique_name scope=spfile";
}
executing Memory Script

sql statement: alter system set  db_name =  ''ORCL19X'' comment= ''Reset to original value by RMAN'' scope=spfile

sql statement: alter system reset  db_unique_name scope=spfile
Oracle instance started

Total System Global Area     234881024 bytes

Fixed Size                     2922904 bytes
Variable Size                176162408 bytes
Database Buffers              50331648 bytes
Redo Buffers                   5464064 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCL19X" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP   1 ( '/apps01/oradata/orcl19xredo01.log' ) SIZE 50 M  REUSE,
  GROUP   2 ( '/apps01/oradata/orcl19xredo02.log' ) SIZE 50 M  REUSE,
  GROUP   3 ( '/apps01/oradata/orcl19xredo03.log' ) SIZE 50 M  REUSE
 DATAFILE
  '/apps01/oradata/orcl19xsystem01.dbf'
 CHARACTER SET AL32UTF8


contents of Memory Script:
{
   set newname for tempfile  1 to
 "/apps01/oradata/orcl19xtemp01.dbf";
   switch clone tempfile all;
   catalog clone datafilecopy  "/apps01/oradata/orcl19x/EXAMPLE6345.dbf",
 "/apps01/oradata/orcl19xsysaux01.dbf",
 "/apps01/oradata/orcl19xundotbs01.dbf",
 "/apps01/oradata/orcl19xexample01.dbf",
 "/apps01/oradata/orcl19xusers01.dbf",
 "/apps01/oradata/orcl19x/EXAMPLE12625.dbf",
 "/apps01/oradata/orcl19x/SYSAUX18237.dbf",
 "/apps01/oradata/orcl19x/SYSTEM9302.dbf",
 "/apps01/oradata/orcl19x/EXAMPLE7187.dbf";
   switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /apps01/oradata/orcl19xtemp01.dbf in control file

cataloged datafile copy
datafile copy file name=/apps01/oradata/orcl19x/EXAMPLE6345.dbf RECID=1 STAMP=1060112210
cataloged datafile copy
datafile copy file name=/apps01/oradata/orcl19xsysaux01.dbf RECID=2 STAMP=1060112210
cataloged datafile copy
datafile copy file name=/apps01/oradata/orcl19xundotbs01.dbf RECID=3 STAMP=1060112210
cataloged datafile copy
datafile copy file name=/apps01/oradata/orcl19xexample01.dbf RECID=4 STAMP=1060112210
cataloged datafile copy
datafile copy file name=/apps01/oradata/orcl19xusers01.dbf RECID=5 STAMP=1060112210
cataloged datafile copy
datafile copy file name=/apps01/oradata/orcl19x/EXAMPLE12625.dbf RECID=6 STAMP=1060112210
cataloged datafile copy
datafile copy file name=/apps01/oradata/orcl19x/SYSAUX18237.dbf RECID=7 STAMP=1060112210
cataloged datafile copy
datafile copy file name=/apps01/oradata/orcl19x/SYSTEM9302.dbf RECID=8 STAMP=1060112210
cataloged datafile copy
datafile copy file name=/apps01/oradata/orcl19x/EXAMPLE7187.dbf RECID=9 STAMP=1060112210

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=1060112210 file name=/apps01/oradata/orcl19x/EXAMPLE6345.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=1060112210 file name=/apps01/oradata/orcl19xsysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=1060112210 file name=/apps01/oradata/orcl19xundotbs01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=1060112210 file name=/apps01/oradata/orcl19xexample01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=1060112210 file name=/apps01/oradata/orcl19xusers01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=6 STAMP=1060112210 file name=/apps01/oradata/orcl19x/EXAMPLE12625.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=7 STAMP=1060112210 file name=/apps01/oradata/orcl19x/SYSAUX18237.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=8 STAMP=1060112210 file name=/apps01/oradata/orcl19x/SYSTEM9302.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=9 STAMP=1060112210 file name=/apps01/oradata/orcl19x/EXAMPLE7187.dbf

contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script

database opened
Finished Duplicate Db at 25-DEC-20

released channel: ch1

released channel: ch2

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s