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

TARGET DB – TESTDB ( Also called auxiliary instance )

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

 

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

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

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 )

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:

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:

 

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