RMAN active is one of cloning method used to clone a database on target host without taking backup of the source database.  Make sure that source database is in archivelog mode. Below are the steps.

NOTE:

In 11g, RMAN active cloning is done during image copy( which includes unused blocks) . It means if a datafile is of 31 GB, but only 10GB databas is present, then it will copy the whole 31GB over network.   And it uses the PUSH method , which increases the load on SOURCE host. 

Where as in 12C, RMAN cloning is done using BACKUPSET, i.e instead of 31G, only 10GB will be copied( that is the used data), Which makes it more efficient. It used PULL method, 

 

EXAMPLE:

SOURCE DB – PRODDB 

DESTINATION DB – TESTDB ( Also called auxiliary instance )

NOTE – If your auxiliary instance already exists, then drop the database before starting the cloning.

 

1. Add the tns entry of the both database in  tnsnames.ora file of DESTINATION host :

-- source db tns : 

PRODDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = proddb.dbaclass.com)(PORT = 1532))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = PRODDB)
    )
  )

  
--Target db tns : 

 
TESTDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = testdb.dbaclass.com)(PORT = 1522))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = TESTDB)
    )
  )

2. Create a listener for the target db ( with static registration)

   LISTENER_TESTDB =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = testdb.dbaclass.com)(PORT = 1538))
    ))


SID_LIST_LISTENER_TESTDB =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = TESTDB)
      (ORACLE_HOME = /oracle/app/oracle/product/12.1.0.2/dbhome_1)
      (SID_NAME = TESTDB )
    ))

-- START THE LISTENER 

lsnrctl start LISTENER_TESTDB

3. Copy the pfile from source host :

Copy the pfile from source host to target host and modify the parameters like control_files,diagnostic_dest,audit_dump .
Apart from that add below two (mandatory) parameters in the the pfile of target db pfile.

*.db_file_name_convert = (“< source db db file location> “,”< target db db file location>”)
*.log_file_name_convert= (“< sourcec db redo log location>”,”<target db redo log location”)

it will look as :

*.db_file_name_convert = (“/u03/oracle/oradata/PRODDB”,”/TESTDB/oradata/TESTDB/TESTDB”)
*.log_file_name_convert= (“/u03/oracle/oradata/PRODB”,”/TESTDB/oradata/TESTDB/TESTDB”)

 

NOTE – FOR RAC DATABASE:

alter system set cluster_database=FALSE scope=spfile sid=’*’;

alter system set log_file_name_convert=’+REDOA/PROD/ONLINELOG’,’+REDO01/TEST/ONLINELOG’,’+REDOB/PROD/ONLINELOG’,’+REDO02/TEST/ONLINELOG’,’+PRODARCH02′,’+TESTARCH’  scope=spfile sid=’*’;

alter system set db_create_file_dest=’+DATA’ scope=spfile sid=’*’;

4. Create password file on both source and target db ( keep same password )

-- SOURCE DB ( PRODDB)

cd $ORACLE_HOME/dbs
orapwd file=orapw$ORACLE_SID password=oracle force=y

-- TARGET DB ( TESTDB)

cd $ORACLE_HOME/dbs
orapwd file=orapw$ORACLE_SID password=oracle force=y


NOTE – FOR RAC DB,create password file as below.

orapwd file=’+DATA’ dbuniquename=TESTDB

Enter password for SYS:

5. Start the target db/auxiliary instance ( TESTDB) in nomount state:

export ORACLE_SID=TESTDB
SQL> create spfile from pfile ;
SQL> Startup nomount

6. Check the connection to both source and target as below

run the below command from TEST DB :

rman target sys/oracle@< source db_tns_name>  auxiliary sys/oracle@<target db_tns_name>

i.e
rman target sys/oracle@PRODDB auxiliary sys/oracle@TESTDB

If you are getting any error while running this command, then fix the same, before proceeding further.

7 . Start the cloning:

Now run the below rman script from target db host:

rman target sys/oracle@PRODDB auxiliary sys/oracle@TESTDB

run
{
allocate channel src1 type disk;
allocate channel src2 type disk;
allocate auxiliary channel aux1 type disk;
allocate auxiliary channel aux2 type disk;
allocate auxiliary channel aux3 type disk;
allocate auxiliary channel aux4 type disk;
duplicate target database to TESTDB from active database USING  BACKUPSET ;
}

 

Once this script completed, it will open the target db ( TESTDB) in resetlog mode.  With this cloning completes. 

 

NOTE: If your oracle version is 11g, then use the below rman script.

run
{
allocate channel src1 type disk;
allocate channel src2 type disk;
allocate auxiliary channel aux1 type disk;
allocate auxiliary channel aux2 type disk;
allocate auxiliary channel aux3 type disk;
allocate auxiliary channel aux4 type disk;
duplicate target database to TESTDB from active database;
}

 

FOR EXCLUDING PARTICULAR TABLESPACE WHILE CLONING:

Below is the rman run code from excluding tablespace USER_DATA

run
{
allocate channel src1 type disk;
allocate channel src2 type disk;
allocate auxiliary channel aux1 type disk;
allocate auxiliary channel aux2 type disk;
allocate auxiliary channel aux3 type disk;
allocate auxiliary channel aux4 type disk;
duplicate target database to TESTDB from active database SKIP TABLESPACE "USER_DATA";
}