Tuesday 18 March 2014

Cloning database with RMAN Catalog

 Source database name = prod
Catalog database name = catalog
Target database name = clone

1) Copy Oracle home from source(prod) database machine to target(clone) database machine:-

$ tar -czvf home.tgz db_1
$ scp -r hmoe.tgz oracle@192.168.0.12:/u01
$ tar -xzvf home.tgz

2) Create new Init.ora file for auxiliary database (target database):-
* New changes in init.ora file:-

db_name= clone

DB_FILE_NAME_CONVERT: This parameter transforms the target data file names to the duplicate database data file names.
• LOG_FILE_NAME_CONVERT: This parameter converts the target database redo log file names to the duplicate database redo log file names.

*.Db_file_name_convert='/oradata/oracle/datafiles/prod/','/oradata/datafile'
If you have multiple datafile locations at Source database then:-
*.Db_file_name_convert='/oradata/oracle/datafiles/prod/','/oradata/datafile','/u01/datafiles/prod','/oradata/datafile'*.log_file_name_convert='/oradata/oracle/datafiles/prod/','/oradata/datafile'

3) Create listner.ora on auxiliary(clone) database:-

CLONE =
   (DESCRIPTION_LIST =
     (DESCRIPTION =
         (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.12)(PORT = 1521))
       )
 )
SID_LIST_CLONE =
(SID_LIST =
   (SID_DESC =
     (SID_NAME = clone)
       (SID = clone)
          (ORACLE_HOME = /oradata/oracle/oracle/product/10.2.0/db_1)
        )
   )

4) Create Password file on auxiliary(clone) database:-
$ orapwd file=orapwclone password=manager force=y

5) Configure tnsnames.ora on catalog database for auxiliary(clone) database:-
TO_PROD =
         (DESCRIPTION =
             (ADDRESS_LIST =
                    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.11)(PORT = 1521))
               )
(CONNECT_DATA =
          (SID_NAME = prod)
                (SID = prod)
             )
       )

TO_CLONE =
             (DESCRIPTION =
                  (ADDRESS_LIST =
                         (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.12)(PORT = 1521))
                       )
(CONNECT_DATA =
              (SID_NAME = clone)
                     (SID = clone)
                     )
                )

6) Export the Oracle Home on auxiliary(clone) database:-

$export $ORACLE_HOME=/oradata/oracle/oracle/product/10.2.0/db_1
$export ORACLE_SID=clone


7) Start the Auxiliary database in nomount stage:-

$sqlplus 'as sysdba'
SQL> startup nomount
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 92276304 bytes
Database Buffers 188743680 bytes
Redo Buffers 2973696 bytes

8) Take RMAN backup of Source database(prod):-
* Login to Catalog database and connect to source database(prod)

$ rman catalog rman/rman target test/test@to_prod

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Mar 18 19:46:40 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: PROD (DBID=687831768)
connected to recovery catalog database

RMAN> backup database plus archivelog;

RMAN>backup current controlfile;

9) After backing up Source(prod) database SCP the backup to target(clone)database:-

$scp -r /u01/rman_backp oracle@192.168.0.12:/u01/

10) Connect catalog to Source(prod) and Target(clone) database:-
 login to Catalog database
$rman catalog rman/rman target test/test@to_catalog auxiliary sys/manager@to_clone

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Mar 18 19:53:33 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: PROD (DBID=687831768)
connected to recovery catalog database
connected to auxiliary database: CLONE (DBID=1041372533)

11) After connecting issue the following command to clone Source(prod) database to Target(clone):-

RMAN>duplicate target database to 'clone';                    (here 'clone' is a SID of the auxiliary database)

Starting Duplicate Db at 18-MAR-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=156 devtype=DISK
allocated channel: ORA_AUX_DISK_2
channel ORA_AUX_DISK_2: sid=155 devtype=DISK
==
==
==
==
==
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 18-MAR-14

12) Go to Cloned database and check the status:-

SQL> select status from v$instance;

STATUS
------------
OPEN

No comments:

Post a Comment

Ask your Questions....