Saturday, September 28, 2013

Duplicate target database from Active in 11g R2

Configuration:

Firstdb on ASUS001N2 which need to be duplicated to Prim on ASUS001N1

Preliminary Steps:

1). Create password file for Source database and database should be in archive log mode
2). Create tns entry for auxiliary database
3). Create Pfile for auxiliary database and include DB_FILE_NAME_CONVERT and LOG_FILE_NAME_CONVERT in pfile.
     Setting these two parameters in RMAN run block gave me errors like "Uneven Number of arguements"
4). Create a password file, with password same as Target database.
5). Create password file and listener for auxiliary database.
6). Create tns entry for auxiliary database in target database.

From Target database side:

We need to give SYS password for both Target and Auxiliary databases.. This is Mandatory..

export ORACLE_SID=<Target>

rman target sys/<pwd> auxiliary sys/<pwd>@<auxiliary_alias>
run {
allocate channel c1 type disk;
allocate auxiliary channel c2 type disk;
 DUPLICATE TARGET DATABASE TO Prim from ACTIVE DATABASE
;
}

Add temporary datafile to the database iff needed..
=====================================================================
RMAN> run {
allocate channel c1 type disk;
allocate auxiliary channel c2 type disk;
 DUPLICATE TARGET DATABASE TO Prim from ACTIVE DATABASE
;
}2> 3> 4> 5> 6>

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

allocated channel: c2
channel c2: SID=5 device type=DISK

Starting Duplicate Db at 28-SEP-13

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    1068937216 bytes

Fixed Size                     2220200 bytes
Variable Size                620760920 bytes
Database Buffers             440401920 bytes
Redo Buffers                   5554176 bytes
allocated channel: c2
channel c2: SID=130 device type=DISK

contents of Memory Script:
{
   sql clone "alter system set  db_name =
 ''FIRSTDB'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name =
 ''PRIM'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   backup as copy current controlfile auxiliary format  '/u02/oradata_Primary/control01.ctl';
   alter clone database mount;
}
executing Memory Script

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

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

Oracle instance shut down

Oracle instance started

Total System Global Area    1068937216 bytes

Fixed Size                     2220200 bytes
Variable Size                620760920 bytes
Database Buffers             440401920 bytes
Redo Buffers                   5554176 bytes
allocated channel: c2
channel c2: SID=130 device type=DISK

Starting backup at 28-SEP-13
channel c1: starting datafile copy
copying current control file
output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_FIRSTDB.f tag=TAG20130928T105724 RECID=12 STAMP=827319445
channel c1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 28-SEP-13

database mounted

contents of Memory Script:
{
   set newname for datafile  1 to
 "/u02/oradata_Primary/system01.dbf";
   set newname for datafile  2 to
 "/u02/oradata_Primary/sysaux01.dbf";
   set newname for datafile  3 to
 "/u02/oradata_Primary/undotbs01.dbf";
   set newname for datafile  4 to
 "/u02/oradata_Primary/users01.dbf";
   set newname for datafile  5 to
 "/u02/oradata_Primary/users02.dbf";
   set newname for datafile  6 to
 "/u02/oradata_Primary/usersindx01.dbf";
   backup as copy reuse
   datafile  1 auxiliary format
 "/u02/oradata_Primary/system01.dbf"   datafile
 2 auxiliary format
 "/u02/oradata_Primary/sysaux01.dbf"   datafile
 3 auxiliary format
 "/u02/oradata_Primary/undotbs01.dbf"   datafile
 4 auxiliary format
 "/u02/oradata_Primary/users01.dbf"   datafile
 5 auxiliary format
 "/u02/oradata_Primary/users02.dbf"   datafile
 6 auxiliary format
 "/u02/oradata_Primary/usersindx01.dbf"   ;
   sql 'alter system archive log current';
}
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

Starting backup at 28-SEP-13
channel c1: starting datafile copy
input datafile file number=00002 name=/u02/oradata/sysaux01.dbf
output file name=/u02/oradata_Primary/sysaux01.dbf tag=TAG20130928T105730
channel c1: datafile copy complete, elapsed time: 00:01:05
channel c1: starting datafile copy
input datafile file number=00004 name=/u02/oradata/users01.dbf
output file name=/u02/oradata_Primary/users01.dbf tag=TAG20130928T105730
channel c1: datafile copy complete, elapsed time: 00:00:15
channel c1: starting datafile copy
input datafile file number=00005 name=/u02/oradata/users02.dbf
output file name=/u02/oradata_Primary/users02.dbf tag=TAG20130928T105730
channel c1: datafile copy complete, elapsed time: 00:00:35
channel c1: starting datafile copy
input datafile file number=00001 name=/u02/oradata/system01.dbf
output file name=/u02/oradata_Primary/system01.dbf tag=TAG20130928T105730
channel c1: datafile copy complete, elapsed time: 00:00:07
channel c1: starting datafile copy
input datafile file number=00003 name=/u02/oradata/undotbs01.dbf
output file name=/u02/oradata_Primary/undotbs01.dbf tag=TAG20130928T105730
channel c1: datafile copy complete, elapsed time: 00:00:03
channel c1: starting datafile copy
input datafile file number=00006 name=/u02/oradata/usersindx01.dbf
output file name=/u02/oradata_Primary/usersindx01.dbf tag=TAG20130928T105730
channel c1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 28-SEP-13

sql statement: alter system archive log current

contents of Memory Script:
{
   backup as copy reuse
   archivelog like  "/u02/oradata/archive/1_14_826920749.dbf" auxiliary format
 "/u01/app/home/oracle/product/11.2.0/my_db/dbs/arch1_14_826920749.dbf"   ;
   catalog clone archivelog  "/u01/app/home/oracle/product/11.2.0/my_db/dbs/arch1_14_826920749.dbf";
   switch clone datafile all;
}
executing Memory Script

Starting backup at 28-SEP-13
channel c1: starting archived log copy
input archived log thread=1 sequence=14 RECID=24 STAMP=827319577
output file name=/u01/app/home/oracle/product/11.2.0/my_db/dbs/arch1_14_826920749.dbf RECID=0 STAMP=0
channel c1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 28-SEP-13

cataloged archived log
archived log file name=/u01/app/home/oracle/product/11.2.0/my_db/dbs/arch1_14_826920749.dbf RECID=24 STAMP=827319578

datafile 1 switched to datafile copy
input datafile copy RECID=12 STAMP=827319578 file name=/u02/oradata_Primary/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=13 STAMP=827319578 file name=/u02/oradata_Primary/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=14 STAMP=827319578 file name=/u02/oradata_Primary/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=15 STAMP=827319578 file name=/u02/oradata_Primary/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=16 STAMP=827319578 file name=/u02/oradata_Primary/users02.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=17 STAMP=827319578 file name=/u02/oradata_Primary/usersindx01.dbf

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

executing command: SET until clause

Starting recover at 28-SEP-13

starting media recovery

archived log for thread 1 with sequence 14 is already on disk as file /u01/app/home/oracle/product/11.2.0/my_db/dbs/arch1_14_826920749.dbf
archived log file name=/u01/app/home/oracle/product/11.2.0/my_db/dbs/arch1_14_826920749.dbf thread=1 sequence=14
media recovery complete, elapsed time: 00:00:00
Finished recover at 28-SEP-13

contents of Memory Script:
{
   shutdown clone immediate;
   startup clone nomount;
   sql clone "alter system set  db_name =
 ''PRIM'' 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

database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    1068937216 bytes

Fixed Size                     2220200 bytes
Variable Size                620760920 bytes
Database Buffers             440401920 bytes
Redo Buffers                   5554176 bytes
allocated channel: c2
channel c2: SID=130 device type=DISK

sql statement: alter system set  db_name =  ''PRIM'' 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    1068937216 bytes

Fixed Size                     2220200 bytes
Variable Size                620760920 bytes
Database Buffers             440401920 bytes
Redo Buffers                   5554176 bytes
allocated channel: c2
channel c2: SID=130 device type=DISK
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "PRIM" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      2
  MAXDATAFILES       30
  MAXINSTANCES     1
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 ( '/u02/oradata_Primary/redo1a.log' ) SIZE 50 M  REUSE,
  GROUP  2 ( '/u02/oradata_Primary/redo2a.log', '/u02/oradata_Primary/redo2b.log' ) SIZE 50 M  REUSE,
  GROUP  3 ( '/u02/oradata_Primary/redo3a.log' ) SIZE 50 M  REUSE
 DATAFILE
  '/u02/oradata_Primary/system01.dbf'
 CHARACTER SET AL32UTF8


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

executing command: SET NEWNAME

renamed tempfile 1 to /u02/oradata_Primary/temp01.dbf in control file

cataloged datafile copy
datafile copy file name=/u02/oradata_Primary/sysaux01.dbf RECID=1 STAMP=827319598
cataloged datafile copy
datafile copy file name=/u02/oradata_Primary/undotbs01.dbf RECID=2 STAMP=827319598
cataloged datafile copy
datafile copy file name=/u02/oradata_Primary/users01.dbf RECID=3 STAMP=827319598
cataloged datafile copy
datafile copy file name=/u02/oradata_Primary/users02.dbf RECID=4 STAMP=827319598
cataloged datafile copy
datafile copy file name=/u02/oradata_Primary/usersindx01.dbf RECID=5 STAMP=827319598

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=827319598 file name=/u02/oradata_Primary/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=827319598 file name=/u02/oradata_Primary/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=827319598 file name=/u02/oradata_Primary/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=827319598 file name=/u02/oradata_Primary/users02.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=827319598 file name=/u02/oradata_Primary/usersindx01.dbf

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

database opened
Finished Duplicate Db at 28-SEP-13
released channel: c1
released channel: c2

RMAN> exit


Recovery Manager complete.

No comments:

Post a Comment