You are on page 1of 4

Active Database Duplication Using RMAN

Active database duplication is used to copy the live running Database


(Target) to the destination instance (Auxiliary) over the network. There
is no use of backup at all.
RMAN does the following while performing active duplication:
Creation of control file on auxiliary database instance.
Restart and mount the cloned instance using duplicate control file.
Creates duplicate datafiles using target database instance.
Recovers datafiles using archived logs.
Redo logs cannot be used for recovery as RMAN does not take backup of
online redo logs. RMAN can recover up to the last redo log file which
was archived.
Finally opens the auxiliary DB in RESETLOGS option.

Environment Details:
Target Database Instance Name
Target Server Hostname
Auxiliary Database Instance Name
Auxiliary Server Hostname

SRDB1
lxsrv11
CLDB1
lxsrv22

In this document Auxiliary database instance (CLDB1) is being duplicated


using Target database instance (SRDB1).
It is assumed that target database instance (SRDB1) is already setup and
running fine. Auxiliary database instance (CLDB1) will be created using RMAN
duplicate option by following below step-by-step procedure:
1. Created below directories on host lxsrv22:
mkdir
mkdir
mkdir
mkdir
mkdir
mkdir
mkdir
mkdir

-p
-p
-p
-p
-p
-p
-p
-p

/opt/app/oracle/admin/CLDB1/adump
/opt/app/oracle/admin/CLDB1/bdump
/opt/app/oracle/admin/CLDB1/cdump
/opt/app/oracle/admin/CLDB1/udump
/ora/db001/data001/CLDB1
/ora/db001/redo001/CLDB1
/ora/db001/redo002/CLDB1
/ora/db001/dbfra001/CLDB1

2. Create initCLDB1.ora (pfile) on host lxsrv22 with below contents and


saved it in $ORACLE_HOME/dbs location:
db_name
instance_name
service_names
compatible
control_files

= CLDB1
= CLDB1
= CLDB1
= 11.2.0.3
= /ora/db001/data001/CLDB1/control_CLDB1_01.ctl,
/ora/db001/redo001/CLDB1/Control_CLDB1_02.ctl,
Page 1 of 4

/ora/db001/redo002/CLDB1/Control_CLDB1_03.ctl
_trace_files_public
= TRUE
diagnostic_dest
= /opt/app/oracle/admin/CLDB1/bdump
core_dump_dest
= /opt/app/oracle/admin/CLDB1/cdump
db_file_name_convert
=
('/ora/db001/data001/SRDB1/','/ora/db001/data001/CLDB1/','/ora/db001/dbfra00
1/SRDB1/','/ora/db001/dbfra001/CLDB1/')
log_file_name_convert
=
('/ora/db001/redo001/SRDB1/','/ora/db001/redo001/CLDB1/','/ora/db001/redo002
/SRDB1/','/ora/db001/redo002/CLDB1/')
remote_login_passwordfile = EXCLUSIVE
db_block_size
= 8192
db_block_buffers
= 10000
shared_pool_size
= 224503555
shared_pool_reserved_size = 1048576
java_pool_size
= 67108864
log_checkpoint_interval = 10000
log_checkpoint_timeout = 1800
processes
= 150
log_buffer
= 32768
sort_area_size
= 1048576
sort_area_retained_size = 1048576
open_cursors
= 2000
nls_date_format
= DD-MON-RR
db_file_multiblock_read_count = 8
job_queue_processes
= 2
utl_file_dir
= *
timed_statistics
= true
# if you want timed statistics
max_dump_file_size
= 10240
# limit trace file size to 5M each
hash_area_size
= 10485760
audit_file_dest
= /opt/app/oracle/admin/CLDB1/adump
log_archive_dest_1
= "location=/ora/db001/dbfra001/CLDB1"
log_archive_format
= arch_CLDB1_%s_%t_%r.arc
dml_locks
= 100
optimizer_mode
= CHOOSE
optimizer_index_caching = 90
optimizer_index_cost_adj = 10
audit_trail = DB
3. Ran below commands on host lxsrv22 to set the database & create password
file:
[oracle@testsrv]$ export ORACLE_SID=CLDB1
[oracle@testsrv]$ export ORACLE_HOME=/opt/app/oracle/product/11.2.0/dbhome_1
[oracle@testsrv]$ orapwd
file=/opt/app/oracle/product/11.2.0/dbhome_1/dbs/orapwCLDB1
password=welcome123
4. Create TNS entry for both the databases (SRDB1 and CLDB1) in tnsnames.ora
of both the servers (lxsrv11 and lxsrv22 for active database duplication):
SRDB1 =
(DESCRIPTION =
(ADDRESS_LIST =
Page 2 of 4

(ADDRESS = (PROTOCOL = tcp) (HOST = lxsrv11.dc.contoso.com) (PORT


= 1521)))
(CONNECT_DATA = (SERVICE_NAME = SRDB1)))
CLDB1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = tcp) (HOST = lxsrv22.dc.contoso.com) (PORT
= 1521)))
(CONNECT_DATA = (SERVICE_NAME = CLDB1)))
5. Register the CLDB1 database name statically in listener.ora file on host
lxsrv22:
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = CLDB1)
(ORACLE_HOME = /opt/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = CLDB1)
)
)
6. Test the connection string for both the servers and databases. Make sure
you are able to connect via TNS name from both the databases locally as well
as remotely:
[oracle@testsrv]$
[oracle@testsrv]$
[oracle@testsrv]$
[oracle@testsrv]$

rman target sys/ welcome123@SRDB1


rman auxiliary sys/ welcome123@CLDB1
sqlplus sys/welcome123@SRDB1 as sysdba
sqlplus sys/welcome123@CLDB1 as sysdba

7. Start the auxiliary database instance in NOMOUNT mode using below steps:
[oracle@testsrv]$ export ORACLE_SID=CLDB1
[oracle@testsrv]$ export ORACLE_HOME=/opt/app/oracle/product/11.2.0/dbhome_1
[oracle@testsrv]$ sqlplus / as sysdba
[oracle@testsrv]$ startup nomount pfile=
/opt/app/oracle/product/11.2.0/dbhome_1/dbs/initCLDB1.ora;
Verify that the instance is started in nomount mode and exit:
SQL> select instance_name, status from v$instance;
SQL> exit
8. Connect RMAN using below string:
[oracle@testsrv]$ rman target sys/cracker@SRDB1 auxiliary
sys/welcome123@CLDB1
Page 3 of 4

RMAN> duplicate target database to CLDB1 from active database;


Note: Above command is actually going to perform database duplication and
will take time depending on the size of the database, network bandwidth etc.
9. Once the database is created you can rename the datafile in duplicate DB
if you wish. To do this first get the database in mount state & use:
SQL> host mv /ora/db001/data001/CLDB1/SRDB1system.dbf
/ora/db001/data001/CLDB1/CLDB1system.dbf
SQL> alter database rename file '/ora/db001/data001/CLDB1/SRDB1system.dbf'
to '/ora/db001/data001/CLDB1/CLDB1system.dbf';
Metalink documents referred for troubleshooting the issues encountered:
1. Connection to Auxiliary using connect string failed with ORA-12528
(Doc ID 419440.1)
2. RMAN Duplicate fails to open CLONE with ORA-01139 when the wrong undo
tablespace is specified for the auxiliary (Doc ID 1536368.1)
3. How to Recreate a Controlfile (Doc ID 735106.1)

Page 4 of 4