Wednesday, September 22, 2010

Duplicate Database Using RMAN Active Database

New Feature in Oracle 11g

Overview

Oracle Database 11g RMAN introduces the FROM ACTIVE DATABASE capability to the DUPLICATE command.


Now when taking the backup of the Primary database you can simultaneously create and restore the database over the network in parallel streams. Apart from some simple Oracle Net setup, and creating a couple of directories and an interim password file, the whole database creation can be done in one RMAN script.

RMAN will automatically copy the server parameter file to the target host, start the auxiliary instance with the server parameter file, restore a backup control file, and copy all necessary database files and archived redo logs over the network to the target host.

Steps:-

On Source server
1.     Source database in archive log mode

On Target server
2. Add entry in /etc/oratab
3. Set Oracle environment using . oraenv
   duporcl
4. Create init.ora file eg. initduporcl.ora file under $ORACLE_HOME/dbs
      echo DB_NAME=duorcl >  $ORACLE_HOME/dbs/initduporcl.ora
5. Create password file
   cd $ORACLE_HOME/dbs
   orapwd  file=orapwduporcl
   enter password when prompted
6. Add service name for source and duplicate database to tnsnames.ora  
 tnsnames.ora

orcl =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = tiger)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
 

duporcl =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = tiger)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = duporcl)
    )
  )
 

7. Add database service entry to listener.ora  and bounce listener
    listener.ora

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =

     (ADDRESS = (PROTOCOL = IPC)(KEY = duporcl))
   )
  )
 


     SID_LIST_LISTENER =
    ( SID_LIST =
    ( SID_DESC =
    ( GLOBAL_DBNAME = duporcl)
    ( ORACLE_HOME = /ora01/oracle/product/11.2.0/db )
    ( SID_NAME = duporcl )
  )
)
 

$ lsnrctl reload
8. Make directories in Target server
    mkdir $ORACLE_BASE/admin/duporcl
    mkdir $ORACLE_BASE/admin/duporcl/adump
    make directories for datafiles
9. startup NOMOUNT  <-duporcl database
10. Create script to duplicate database
       example : Script dup.cmd
          run {
              allocate channel ch1 type disk;
              allocate auxiliary channel ch2 type disk;
              duplicate target database to duporcl from active database ;
              }
14. use RMAN to create duplicate database
    rman target sys/manager@orcl auxiliary  sys/manager@demo2 cmdfile=dup.cmd
15. check, check, check and test connectivity