Thursday, 10 September 2020

Oracle: Clone/Duplicate database from physical standby database

Basic steps:

1.Cancel MRP on Standby database/shutdown/startup(default opens in readonly mode).

2. Include target tns in source tnsnames.ora

3. Prepare target.

  • Listener.ora
  • source and target tns in tnsnames.ora
  • passwd file from source in $ORACLE_HOME/dbs
  • start instance in nomount. (New setup: need to cook init.ora either from source or any other way
  • Verify paths like controlfile/datafile/logfile etc exist.
4. Fire the duplicate command.
-----------------------------------SYNTAX and MISC information------------------------------------------

 Procedure is same as copying from Primary database with minor difference, put physical standby on RO mode.

RO-Read only.

Steps:

1. Configure Listener(to listen for connection) & copy orapwd.

Sample:

LISTENER = 

  (ADDRESS_LIST =

        (ADDRESS=

          (PROTOCOL=IPC)

          (KEY= CloneDB.world)

        )

        (ADDRESS =

          (PROTOCOL = TCP)

         (Host =<CloneDB Host>)

          (Port = <PORT>)

        )

  )

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = <CloneDB>)

      (ORACLE_HOME = <Valid Home Path>)

    )

  )

2. Prepare TNS: Both source(Physical Standby) and Destination and init.ora(copy from source and adjust for DB & LOG convert parameters)

Sample:(Format :'Source path','Target Path', ........for each path in source)

*.db_file_name_convert='/u02/ORACLE/dbs','/u001/oradata/db,'/u03/ORACLE/dbs','/u002/oradata/db'

*.log_file_name_convert='/u02/ORACLE/redo','/u003/oradata/db','/u03/ORACLE/redo','/u004/oradata/db'

3. Open Physical standby in RO mode:

a. Cancel recovery.: alter database recover managed standby database cancel;

b. Shutdown immediate.

c. startup (This will open physical standby in RO mode automatically) 

Note : TNS connection entries needed  in tnsnames.ora both side(source/target)

Fireup RMAN:

rman target sys/pwd@<physicalstandby tns>  auxiliary sys/pwd@<DuplicateDB tns>

run

{

allocate channel T1 type disk;

allocate channel T2 type disk;

allocate channel T3 type disk;

allocate channel T4 type disk;

allocate auxiliary channel A1 type disk;

allocate auxiliary channel A2 type disk;

allocate auxiliary channel A3 type disk;

allocate auxiliary channel A4 type disk;

DUPLICATE TARGET DATABASE TO 'sblut1db' FROM ACTIVE DATABASE NOFILENAMECHECK;

Number of channels may help to speedup the duplication process, be aware of load on the system(IO/CPU).

Additional info:

a. if duplicate fails fix the problem, normally would be 'missed' path creation.

b. UNDO tablespace parameter should either same or commented altogether, if different duplication would fail.