Sunday, February 23, 2020

RMAN Active cloning method

RMAN Active cloning method 



EXAMPLE:

SOURCE DB – QPROD ( Also called target instance )
DESTINATION DB – QTEST ( Also called auxiliary instance )

NOTE – If your auxiliary instance already exists, then drop the database before starting the cloning.


1. Add the tns entry of the both database in tnsnames.ora file of DESTINATION host :

-- source db tns :

QPROD =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac1.oracle.com)(PORT = 1528))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = QPROD)
    )
  )


--Target db tns :


QTEST =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac2.oracle.com)(PORT = 1533))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = QTEST)
    )
  )


2. Create a listener for the target db ( with static registration)

 LISTENER_QTEST =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = rac2.oracle.com)(PORT = 1533))
    ))


SID_LIST_LISTENER_QTEST =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = QTEST)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
      (SID_NAME = TESTDB )
    ))


-- START THE LISTENER

lsnrctl start LISTENER_TESTDB


3. Copy the pfile from source host :

Copy the pfile from source host to target host and modify the parameters like control_files,diagnostic_dest,audit_dump .
Apart from that add below two (mandatory) parameters in the the pfile of target db pfile.

*.db_file_name_convert = '/u09/QPROD', '/u01/QTEST'('< source db db file location> ','< target db db file location>')
*.log_file_name_convert= '/u09/QPROD', '/u01/QTEST'('< sourcec db redo log location>','<target db redo log location')


NOTE – FOR RAC DATABASE:

alter system set cluster_database=FALSE scope=spfile sid='*';
alter system set log_file_name_convert=’+REDOA/PROD/ONLINELOG’,’+REDO01/TEST/ONLINELOG’,’+REDOB/PROD/ONLINELOG’,’+REDO02/TEST/ONLINELOG’,’+PRODARCH02′,’+TESTARCH’  scope=spfile sid=’*’;
alter system set db_create_file_dest=’+DATA’ scope=spfile sid='*';

4. Create password file on both source and target db ( keep same password )

-- SOURCE DB ( QPROD)

cd $ORACLE_HOME/dbs
orapwd file=orapw$ORACLE_SID password=oracle force=y

-- TARGET DB ( QTEST)

cd $ORACLE_HOME/dbs
orapwd file=orapw$ORACLE_SID password=oracle force=y

NOTE – FOR RAC DB,create password file as below.
orapwd file=’+DATA’ dbuniquename=TESTDB
Enter password for SYS:

5. Start the target db/auxiliary instance ( QTEST) in nomount state:

export ORACLE_SID=QTEST
SQL> create spfile from pfile ;
SQL> startup nomount

6. Check the connection to both source and target as below

run the below command from QTEST:
rman target sys/oracle@< source db_tns_name>  auxiliary sys/oracle@<target db_tns_name>
i.e
rman target sys/oracle@QPROD auxiliary sys/oracle@QTEST
If you are getting any error while running this command, then fix the same, before proceeding further.

7 . Start the cloning:

Now run the below rman script from target db host:
rman target sys/oracle@PRODDB auxiliary sys/oracle@TESTDB

run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate auxiliary channel aux1 type disk;
allocate auxiliary channel aux2 type disk;
allocate auxiliary channel aux3 type disk;
allocate auxiliary channel aux4 type disk;
duplicate target database to QTEST from active database USING  BACKUPSET ;
}

Once this script completed, it will open the target db (QTEST) in resetlog mode.  With this cloning completes.

NOTE: If your oracle version is 11g, then use the below rman script.

run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate auxiliary channel aux1 type disk;
allocate auxiliary channel aux2 type disk;
allocate auxiliary channel aux3 type disk;
allocate auxiliary channel aux4 type disk;
duplicate target database to QTEST from active database;
}

for excluding particular tablespace while cloning:

Excluding tablespace Q_DATA.

run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate auxiliary channel aux1 type disk;
allocate auxiliary channel aux2 type disk;
allocate auxiliary channel aux3 type disk;
allocate auxiliary channel aux4 type disk;
duplicate target database to QTEST from active database SKIP TABLESPACE "Q_DATA";
}

No comments:

Post a Comment