5 April 2014

Steps to create RMAN Active duplicate in 11gR2

Steps to create RMAN Active duplicate in 11gR2

Introduction
RMAN has the ability to duplicate, or clone, a database from a backup or from an active database. It is possible to create a duplicate database on a remote server with the same file structure, a remote server will a different file structure or the local server with a different file structure.
The article assumes the active duplicate database is being created on a separate server. In this test case the target database is PROD and duplicate database will be TEST.

Preparation of PROD database
  • Create password file on PROD and scp to TEST DB ($ORACLE_HOME/dbs location)
orapwd file=$ORACLE_HOME/dbs/orapwTEST password=password entries=10

scp password file to TEST server ($ORACLE_HOME/dbs location)
  • Make proper entries in tnsnames.ora in both PROD and TEST database
Sample entry as below mention:-
# Generated by Oracle configuration tools.
PROD =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dev1.localdomain.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = PROD) (UR=A)
    )
  )

TEST =
 (DESCRIPTION =
 (ADDRESS = (PROTOCOL = TCP)(HOST = dev2.localdomain.com)(PORT = 1521))
 (CONNECT_DATA =
 (SERVER = DEDICATED)
 (SERVICE_NAME = TEST)(UR=A)
 )
 )

Preparation of TEST database.
  • Create pfile (ORACLE_HOME/dbs/initTEST.ora)
*.DB_NAME=TEST
*.DB_UNIQUE_NAME=TEST
*.diagnostic_dest='/u01/app/oracle'
*.db_block_size=8192
*.Memory_TARGET=843055104
*.COMPATIBLE= 11.2.0.0.0
*.local_listener='(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = dev2.localdomain.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = TEST)(UR=A)))'
*.log_file_name_convert='/u01/app/oracle/oradata/ora11g/','/u01/app/oracle/oradata/TEST/','/u01/app/oracle/oradata/PROD/','/u01/app/oracle/oradata/TEST/'
*.db_file_name_convert='/u01/app/oracle/oradata/ora11g/','/u01/app/oracle/oradata/TEST/','/u01/app/oracle/oradata/PROD/','/u01/app/oracle/oradata/TEST/'


  • Make proper entries in tnsnames.ora and listener.ora
Sample entry is as below mention
cat tnsnames.ora
# Generated by Oracle configuration tools.
PROD =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dev1.localdomain.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = PROD) (UR=A)
    )
  )

TEST =
 (DESCRIPTION =
 (ADDRESS = (PROTOCOL = TCP)(HOST = dev2.localdomain.com)(PORT = 1521))
 (CONNECT_DATA =
 (SERVER = DEDICATED)
 (SERVICE_NAME = TEST)(UR=A)
 )
)

cat listener.ora
INBOUND_CONNECT_TIMEOUT_LISTENER = 0
TEST =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = dev2.localdomain.com)(PORT = 1521))
      )
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
      )
    )
  )

SID_LIST_TEST =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/11.3.0)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = TEST)
      (ORACLE_HOME = /u01/app/oracle/product/11.3.0)
      (SID_NAME = TEST)
    )
  )

ADR_BASE_REPL = /u01/app/oracle

  • Make proper directory structure on TEST DB for Datafile and logfile
  •  Test connection from both database (PROD/TEST). We should be able to connect sqlplus from both PROD and TEST database.
sqlplus sys/Welcome123@PROD as sysdba
sqlplus sys/Welcome123@TEST as sysdba

  • Start TEST database in nomount
export ORACLE_HOME= /u01/app/oracle/product/11.3.0
export ORACLE_SID=TEST
export PATH=$ORACLE_HOME/bin:$PATH

sqlplus >startup nomount pfile=’$ORACLE_HOME/dbs/initTEST.ora’
  • Connect with RMAN
rman target sys/Welcome123@PROD
connect auxiliary sys/Welcome123@TEST

[oracle@dev2 dbs]$ rman target sys/Welcome123@PROD

Recovery Manager: Release 11.2.0.3.0 - Production on Sat Apr 5 11:45:02 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PROD (DBID=255635113)

RMAN> connect auxiliary sys/Welcome123@TEST

connected to auxiliary database: TEST (not mounted)

RMAN>

DUPLICATE TARGET DATABASE TO "TEST" FROM ACTIVE DATABASE;

SQL> select name from v$database;

NAME
---------
TEST

Sqlplus > create pfile from spfile;

Your TEST database is ready now.




No comments:

Post a Comment