Monday 10 December 2012

Rman Active Database Duplication



Rman Active Database Duplicate 11g R2

Environment Information:
Source:
OS: Centos,RHEL5 or any Liux or Unix based OS
Hostname: centos_1.localdomain
IP: 192.168.78.128
DB Name: orcl
Target:
OS: Centos
Hostname: centos_2.localdomain
IP: 192.168.78.129
DB Name: db
Prerequisites
* The source database must be in ARCHIVELOG mode if it is open.
* If the source database is in NOARCHIVELOG mode, it should be mounted after a clean shut down.
* Connections to the auxiliary instance must be through a Net service name.
* The auxiliary instance must have a password file created, the password for the SYSDBA user used for the         activity must be the same.
Step by Step:
       1.  Create tns entries for both DBs (source and target). And copy tnsnames.ora to target machine.
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.78.128)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
DB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.78.129)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = db)
    )
  )
        Create Listener entries for both DB Servers (source and target).
Listener.ora for Source Server.

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (SID_NAME = orcl)
    )
  )

LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.78.128)(PORT = 1521))
  )

ADR_BASE_LISTENER = /u01/app/oracle
-------------------------------------------------------------------
Listener.ora for Target Server.
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = db)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (SID_NAME = db)
    )
  )

LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.78.129)(PORT = 1521))
  )

ADR_BASE_LISTENER = /u01/app/oracle


     2. Create required directories on target.
------Create Following directories on target DB Server-------
mkdir -p /u01/app/oracle/flash_recovery_area/db/archivelog
mkdir -p /u01/app/oracle/flash_recovery_area/db/onlinelog
mkdir -p /u01/app/oracle/flash_recovery_area/db/flashback
mkdir -p /u01/app/oracle/admin/db/dpdump
mkdir -p /u01/app/oracle/admin/db/adump
mkdir -p /u01/app/oracle/admin/db/scripts
mkdir -p /u01/app/oracle/admin/db/pfile
mkdir -p /u01/app/oracle/cfgtoollogs/dbca/db
mkdir -p /u01/app/oracle/cfgtoollogs/emca
mkdir -p /u01/app/oracle/cfgtoollogs/netca
mkdir -p /u01/app/oracle/oradata/db                    
mkdir -p /u01/app/oracle/admin/db/adump           

      3.    Create listener.
    Using netca
      4.   Configure listener to use static service registration.            
    Using netmgr
        5.   Reload the listener
    lsnrctl reload
      6.    Ping  from both machine (IPs and tns entries)
    Ping 192.168.78.129
    Ping 192.168.78.128
    Tnsping orcl
    Tnsping db
      7.   Create password file on source (oracle home/dbs/) for target and copy to target.
    [oracle@centos_1 dbs]$ orapwd file=orapwdb password=oracle
       8.    [oracle@centos_1 dbs]$ scp orapwdb        oracle@192.168.78.128:/u01/app/oracle/product/11.2.0/db_1/dbs
      9.  Create a dummy parameter file (Pfile)with only one parameter on Target.
   Vi /backup/pfile.ora
   Db_name=db
      10. Start and verify the auxiliary instance
   Start the auxiliary instance; verify the parameters db_name and control_files.
   SQL> Startup nomount pfile=’/backup/pfile.ora’
   SQL> show parameter db_name;
   SQL> show parameter control_files;
      11. Connect to rman using target and auxiliary
         man target=sys/oracle@orcl auxiliary=sys/oracle@db
        12.  Perform Oracle 11g Active database duplication
   Run following command in rman prompt.

RMAN>
run {
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate channel prmy3 type disk;
allocate channel prmy4 type disk;
allocate channel prmy5 type disk;
allocate auxiliary channel stby1 type disk;
 DUPLICATE TARGET DATABASE TO db from active database
 spfile
 set db_file_name_convert '/orcl/','/db/'
 set log_file_name_convert '/orcl/','/db/'
set control_files='/u01/app/oracle/oradata/db/control01.ctl', '/u01/app/oracle/oradata/db/control02.ctl'
 NOFILENAMECHECK;
}





















    13.  Last output will be like this. If rman process completed successfully.


database opened
Finished Duplicate Db at 05-JAN-11
released channel: prmy1
released channel: prmy2
released channel: prmy3
released channel: prmy4
released channel: prmy5
released channel: stby1

------------------------------END-----------------------------------





No comments:

Post a Comment