Saturday, 4 November 2023

create clone database from standby database using Duplicate command

 

If we have a method to create clone database from standby database, its bliss for DBAs, they can perform production database clone without impacting production database.

 

In this article we can see how we can create a clone database from standby database using DUPLICATE command.

Source is standby - PRODDB

target is new clone server - TESTDB

 

Steps:

1.     Network configuration between standby server and new clone server

  • configure static listener in target so that database will connect as sysdba in nomount state without any blocking

 SID_LIST_LISTENER=

  (SID_LIST=

    (SID_DESC=

      (SID_NAME= TESTDB)

      (GLOBAL_DBNAME = TESTDB)

      (ORACLE_HOME= /u01/app/oracle/product/19c/db1)

      )

     )

 

·         Enter source and target tns entries in both sides.

TESTDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 9.9.9.9)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = TESTDB)
      (UR=A) 
    )
  )

 

PRODDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 1.1.1.1)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = PRODDB )
      (UR=A)
    )
  )

2.     Create pfile for TESTDB  by taking reference from standby pfile and start in nomount.

3.     Test connectivity.

$rman target sys/passwd@proddb auxiliary sys/passwd@testdb

4.     Stop arch deletion scripts in standby side if configured any,  this is required for retaining archivelogs required for recovery in target side.

 

5.     Use below script to create clone database. In this script we are using FS /oradata, where as source database uses ASM

RUN

{

SET NEWNAME FOR DATABASE TO '/oradata/RMVL/datafiles/%b';

DUPLICATE TARGET DATABASE TO 'RMVL' from active database

  LOGFILE

    GROUP 1 ('/oradata/RMVL/datafiles/redo01a.log') SIZE 4096M REUSE,

    GROUP 2 ('/oradata/RMVL/datafiles/redo02a.log') SIZE 4096M REUSE,

        GROUP 3 ('/oradata/RMVL/datafiles/redo03a.log') SIZE 4096M REUSE;

}

 

 

That’s it, database will open in read write mode after this scripts completed successfully.

 

Happy Cloning 😊