Hungry DBA .com for DBAs who like food
Example of how to clone databases using RMAN

Take a RMAN FULL Backup of the PROD database in order to clone to TEST

$ export ORACLE_SID=PROD
$ rman target /

rman> run
{allocate channel ch1 device type disk format ‘/backup/PROD/%_U’;
backup database plus archivelog;
}

On successful completion the backupsets created can be used for cloning PROD to TEST.

Cloning of TEST database from PROD using RMAN

$ cd $ORACLE_HOME/dbs

orapwd password=oracle entries=20 file=orapwTEST

create initTEST.ora file with the following contents

*._b_tree_bitmap_plans=FALSE
*._index_join_enabled=FALSE
*_kgl_large_heap_warning_threshold=8388608
*._optim_peek_user_binds=FALSE
*.audit_file_dest='/u00/app/oracle/admin/TEST/adump'
*.background_dump_dest='/u00/app/oracle/admin/TEST/bdump'
*.blank_trimming=TRUE
*.compatible='10.2.0.1.0'
*.control_files='/u07/oradata/TEST/ctl1/TEST1.ctl','/u07/oradata/TEST/ctl2/TEST2.ctl'
*.core_dump_dest='/u00/app/oracle/admin/TEST/cdump'
*.db_block_size=8192
*.db_cache_size=1G
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='TEST'
*.instance_name='TEST'
*.java_pool_size=128m
*.job_queue_processes=10
*.log_archive_dest='/u09/oradata/TEST/archdir'
*.log_archive_format='%s_%t_%r.arc'
*.nls_length_semantics='CHAR'
*.open_cursors=300
*.optimizer_secure_view_merging=FALSE
*.pga_aggregate_target=250m
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.shared_pool_size=250m
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u00/app/oracle/admin/TEST/udump'
*.db_file_name_convert=(’/u01/oradata/PROD/’,’ /u07/oradata/TEST/’,’ /u02/oradata/PROD/’,’ /u07/oradata/TEST/’,’ /u03/oradata/PROD/’,
’ /u07/oradata/TEST/’,’ /u04/oradata/PROD/’,’ /u07/oradata/TEST/’)
*.log_file_name_convert=(‘/u05/oradata/PROD/logs/’,’ /u08/oradata/TEST/logs/’)
 
Note that the parameters "db_file_name_convert" and "log_file_name_convert" are used to specify the new location of the files for the TEST database.

Starting up the instance TEST for the cloning purpose

$ export ORACLE_SID=TEST

SQL> connect / as sysdba
SQL>startup nomount;
SQL> exit;
$ export ORACLE_SID=PROD
$ rman target / auxiliary
sys/oracle@TEST

rman> run
{allocate auxiliary channel aux1 device type disk format ‘/backup/PROD/%_U’;
duplicate target database to "TEST"
logfile group 1 (‘/u08/oradata/TEST/logs/redo_TEST_11.log’) size 100m,
group 2 (‘/u08/oradata/TEST/logs/redo_TEST_21.log’) size 100m,
group 3 (‘/u08/oradata/TEST/logs/redo_TEST_31.log’) size 100m;
}