***Active database duplication Method***
Target Database- HCL
Auxiliary Database- AUX
Step1. Create a pfile for AUX database and create the required directory as well.
db_name='AUX'
diagnostic_dest='/u01/app/oracle'
DB_FILE_name_CONVERT=('/u01/app/oracle/oradata/HCL','/u01/app/oracle/oradata/AUX')
LOG_FILE_NAME_CONVERT=( '/u01/app/oracle/oradata/HCL','/u01/app/oracle/oradata/AUX')
sga_target=377487360
control_files='/u01/app/oracle/oradata/AUX/control01.ctl'
compatible='11.2.0.0.0'
Step2. Create password file for Auxilary database
orapwd file=orapwAUX password=oracle entries=10
Step3. Configure Listener on Aux
====================================================
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = AUX)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = AUX)
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.195.128)(PORT = 1521))
)
====================================================
Configure Configure Listener on Target
====================================================
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = HCL)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = HCL)
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.195.134)(PORT = 1521))
)
===========================================================
Configure tnsname.ora (In the TARGET and AUXILIARY host)
=================================================================
AUX =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.195.128)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = AUX)
)
)
HCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.195.134)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = HCL)
)
)
======================================================================
Execute on the TARGET and AUXILIARY host
% tnsping HCL
% tnsping AUX
Step4. Start Auxilary database to nomount stage
SQL> startup nomount pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initAUX.ora';
ORACLE instance started.
Total System Global Area 376635392 bytes
Fixed Size 1336652 bytes
Variable Size 121637556 bytes
Database Buffers 247463936 bytes
Redo Buffers 6197248 bytes
SQL> exit
Step.5
Start RMAN to connect both DB Instances
RMAN> connect target sys/oracle@HCL
connected to target database: HCL (DBID=931429395)
RMAN> connect AUXILIARY sys/oracle@AUX
connected to auxiliary database: AUX (not mounted)
RMAN>
=================
DUPLICATE TARGET DATABASE TO 'AUX' FROM ACTIVE DATABASE DB_FILE_NAME_CONVERT '/u01/app/oracle/oradata/HCL','/u01/app/oracle/oradata/AUX';
See output below
RMAN> DUPLICATE TARGET DATABASE TO 'AUX' FROM ACTIVE DATABASE DB_FILE_NAME_CONVERT '/u01/app/oracle/oradata/HCL','/u01/app/oracle/oradata/AUX';
Starting Duplicate Db at 13-JAN-13
using channel ORA_AUX_DISK_1
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 376635392 bytes
Fixed Size 1336652 bytes
Variable Size 125831860 bytes
Database Buffers 243269632 bytes
Redo Buffers 6197248 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''HCL'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''AUX'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
backup as copy current controlfile auxiliary format '/u01/app/oracle/oradata/AUX/control01.dbf';
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''HCL'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''AUX'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 376635392 bytes
Fixed Size 1336652 bytes
Variable Size 125831860 bytes
Database Buffers 243269632 bytes
Redo Buffers 6197248 bytes
Starting backup at 13-JAN-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=39 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_HCL.f tag=TAG20130113T173439 RECID=7 STAMP=804620080
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 13-JAN-13
database mounted
contents of Memory Script:
{
set newname for datafile 1 to
"/u01/app/oracle/oradata/AUX/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/AUX/sysaux01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/AUX/undotbs01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/AUX/users01.dbf";
backup as copy reuse
datafile 1 auxiliary format
"/u01/app/oracle/oradata/AUX/system01.dbf" datafile
2 auxiliary format
"/u01/app/oracle/oradata/AUX/sysaux01.dbf" datafile
3 auxiliary format
"/u01/app/oracle/oradata/AUX/undotbs01.dbf" datafile
4 auxiliary format
"/u01/app/oracle/oradata/AUX/users01.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
Starting backup at 13-JAN-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/HCL/system01.dbf
output file name=/u01/app/oracle/oradata/AUX/system01.dbf tag=TAG20130113T173446
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:05
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/HCL/sysaux01.dbf
output file name=/u01/app/oracle/oradata/AUX/sysaux01.dbf tag=TAG20130113T173446
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:39
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/HCL/undotbs01.dbf
output file name=/u01/app/oracle/oradata/AUX/undotbs01.dbf tag=TAG20130113T173446
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/HCL/users01.dbf
output file name=/u01/app/oracle/oradata/AUX/users01.dbf tag=TAG20130113T173446
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 13-JAN-13
sql statement: alter system archive log current
contents of Memory Script:
{
backup as copy reuse
archivelog like "/u01/app/oracle/flash_recovery_area/HCL/archivelog/2013_01_13/o1_mf_1_3_8h58tfxh_.arc" auxiliary format
"/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_3_804600981.dbf" ;
catalog clone archivelog "/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_3_804600981.dbf";
switch clone datafile all;
}
executing Memory Script
Starting backup at 13-JAN-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=3 RECID=2 STAMP=804620197
output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_3_804600981.dbf RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 13-JAN-13
cataloged archived log
archived log file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_3_804600981.dbf RECID=2 STAMP=804620199
datafile 1 switched to datafile copy
input datafile copy RECID=7 STAMP=804620199 file name=/u01/app/oracle/oradata/AUX/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=8 STAMP=804620199 file name=/u01/app/oracle/oradata/AUX/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=9 STAMP=804620199 file name=/u01/app/oracle/oradata/AUX/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=10 STAMP=804620199 file name=/u01/app/oracle/oradata/AUX/users01.dbf
contents of Memory Script:
{
set until scn 768903;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 13-JAN-13
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=19 device type=DISK
starting media recovery
archived log for thread 1 with sequence 3 is already on disk as file /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_3_804600981.dbf
archived log file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_3_804600981.dbf thread=1 sequence=3
media recovery complete, elapsed time: 00:00:01
Finished recover at 13-JAN-13
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set db_name =
''AUX'' 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 376635392 bytes
Fixed Size 1336652 bytes
Variable Size 125831860 bytes
Database Buffers 243269632 bytes
Redo Buffers 6197248 bytes
sql statement: alter system set db_name = ''AUX'' 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 376635392 bytes
Fixed Size 1336652 bytes
Variable Size 125831860 bytes
Database Buffers 243269632 bytes
Redo Buffers 6197248 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "AUX" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oracle/oradata/AUX/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/u01/app/oracle/oradata/AUX/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/u01/app/oracle/oradata/AUX/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/u01/app/oracle/oradata/AUX/system01.dbf'
CHARACTER SET WE8MSWIN1252
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/AUX/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/AUX/sysaux01.dbf",
"/u01/app/oracle/oradata/AUX/undotbs01.dbf",
"/u01/app/oracle/oradata/AUX/users01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/AUX/temp01.dbf in control file
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/AUX/sysaux01.dbf RECID=1 STAMP=804620218
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/AUX/undotbs01.dbf RECID=2 STAMP=804620218
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/AUX/users01.dbf RECID=3 STAMP=804620218
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=804620218 file name=/u01/app/oracle/oradata/AUX/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=804620218 file name=/u01/app/oracle/oradata/AUX/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=804620218 file name=/u01/app/oracle/oradata/AUX/users01.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 13-JAN-13
RMAN>