Test

Wednesday, October 26, 2016

DUPLICATE Database using Backup of a Database

If you want to create a duplicate database from a live/active database, you can follow this article. But if you want to DUPLICATE a database using backup of another database, you can use following steps. I am creating new database with a different name using DUPLICATE command, or you may want to retain same name for the database while duplicating.


Source database name is TEST with all files under +DATA/TEST directory.
Destination database name is TESTT, and to have all files under +DATA/TESTT directory.

On a new server where you want to duplicate the database, create inittestt.ora file under $ORACLE_HOME/dbs directory. You can copy and then modify parameter file of TEST database to create pfile for TESTT. For this example, I copied backup of TEST database under /u02/backup directory and this backup will be used to build TESTT database.

Add following lines in inittestt.ora file 
Db_file_name_convert=’+DATA/TEST/’,’+DATA/TESTT’
Log_file_name_convert= ‘+RECO/TEST’,’+RECO/TESTT’
Control_files=’+DATA/TESTT/control01.ctl’,’+DATA/TESTT/control02.ctl’

Start TESTT in nomount mode
$export ORACLE_SID=testt
SQL> startup nomount

Connect to RMAN and do duplicate using backup of TEST

rman auxiliary /
RMAN> duplicate database to testt backup location '/u02/backup/';

Starting Duplicate Db at 26-AUG-16

contents of Memory Script:
{
   sql clone "create spfile from memory";
}
executing Memory Script

sql statement: create spfile from memory

contents of Memory Script:
{
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    1937457152 bytes

Fixed Size                     2254464 bytes
Variable Size                536873344 bytes
Database Buffers            1392508928 bytes
Redo Buffers                   5820416 bytes

contents of Memory Script:
{
   sql clone "alter system set  db_name =
 ''TEST'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name =
 ''TESTT'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone primary controlfile from  '/u02/backup/control.bak';
   alter clone database mount;
}
executing Memory Script

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

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

Oracle instance shut down

Oracle instance started

Total System Global Area    1937457152 bytes

Fixed Size                     2254464 bytes
Variable Size                536873344 bytes
Database Buffers            1392508928 bytes
Redo Buffers                   5820416 bytes

Starting restore at 26-AUG-16
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=23 device type=DISK

channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output file name=+DATA/testt/control01.ctl
output file name=+DATA/testt/control02.ctl
Finished restore at 26-AUG-16

database mounted
released channel: ORA_AUX_DISK_1
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=23 device type=DISK

contents of Memory Script:
{
   set until scn  932969;
   set newname for datafile  1 to
 "+DATA/testt/system01.dbf";
   set newname for datafile  2 to
 "+DATA/testt/sysaux01.dbf";
   set newname for datafile  3 to
 "+DATA/testt/undotbs01.dbf";
   set newname for datafile  4 to
 "+DATA/testt/users01.dbf";
   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

Starting restore at 26-AUG-16
using channel ORA_AUX_DISK_1

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/testt/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to +DATA/testt/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to +DATA/testt/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to +DATA/testt/users01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/test_04re259h_1_1.bak
channel ORA_AUX_DISK_1: piece handle=/u02/backup/test_04re259h_1_1.bak tag=TAG20160824T114448
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 26-AUG-16

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=920891413 file name=+DATA/testt/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=920891413 file name=+DATA/testt/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=7 STAMP=920891413 file name=+DATA/testt/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=8 STAMP=920891413 file name=+DATA/testt/users01.dbf

contents of Memory Script:
{
   set until scn  932969;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 26-AUG-16
using channel ORA_AUX_DISK_1

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=9
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/test_06re25a2_1_1.bak
channel ORA_AUX_DISK_1: piece handle=/u02/backup/test_06re25a2_1_1.bak tag=TAG20160824T114506
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=/u01/app/oracle/product/11.2.0/db/dbs/arch1_9_920718405.dbf thread=1 sequence=9
channel clone_default: deleting archived log(s)
archived log file name=/u01/app/oracle/product/11.2.0/db/dbs/arch1_9_920718405.dbf RECID=1 STAMP=920891413
media recovery complete, elapsed time: 00:00:00
Finished recover at 26-AUG-16
Oracle instance started

Total System Global Area    1937457152 bytes

Fixed Size                     2254464 bytes
Variable Size                536873344 bytes
Database Buffers            1392508928 bytes
Redo Buffers                   5820416 bytes

contents of Memory Script:
{
   sql clone "alter system set  db_name =
 ''TESTT'' 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 =  ''TESTT'' 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    1937457152 bytes

Fixed Size                     2254464 bytes
Variable Size                536873344 bytes
Database Buffers            1392508928 bytes
Redo Buffers                   5820416 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TESTT" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP   1 ( '+DATA/testt/redo01.log' ) SIZE 50 M  REUSE,
  GROUP   2 ( '+DATA/testt/redo02.log' ) SIZE 50 M  REUSE,
  GROUP   3 ( '+DATA/testt/redo03.log' ) SIZE 50 M  REUSE
 DATAFILE
  '+DATA/testt/system01.dbf'
 CHARACTER SET WE8MSWIN1252


contents of Memory Script:
{
   set newname for tempfile  1 to
 "+DATA/testt/temp01.dbf";
   switch clone tempfile all;
   catalog clone datafilecopy  "+DATA/testt/sysaux01.dbf",
 "+DATA/testt/undotbs01.dbf",
 "+DATA/testt/users01.dbf";
   switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to +DATA/testt/temp01.dbf in control file

cataloged datafile copy
datafile copy file name=+DATA/testt/sysaux01.dbf RECID=1 STAMP=920891427
cataloged datafile copy
datafile copy file name=+DATA/testt/undotbs01.dbf RECID=2 STAMP=920891427
cataloged datafile copy
datafile copy file name=+DATA/testt/users01.dbf RECID=3 STAMP=920891427

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=920891427 file name=+DATA/testt/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=920891427 file name=+DATA/testt/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=920891427 file name=+DATA/testt/users01.dbf

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

database opened
Finished Duplicate Db at 26-AUG-16

RMAN> exit






No comments:

Post a Comment

Popular Posts - All Times