This procedure will clone a database onto the same server using RMAN duplicate.

To use RMAN duplicate , an RMAN backup of the source database is required.

1. Create a pfile for the new database
This step assumes that the source database is using a spfile. If that is not the case, simply make a copy the existing pfile.

Connect to the source database as sysdba and run the following:

create pfile='init<new database sid>.ora' from spfile;
This will create a new pfile in the $ORACLE_HOME/dbs directory.

The new pfile will need to be edited immediately. If the cloned database is to have a different name to the source, this will need to be changed, as will any paths. Review the contents of the file and make alterations as necessary.

Because in this example the cloned database will reside on the same machine as the source, Oracle must be told how convert the filenames during the RMAN duplicate operation. This is achieved by adding the following lines to the newly created pfile:

db_file_name_convert=(<source_db_path>,<target_db_ path>)
log_file_name_convert=(<source_db_path>,<target_db _path>)

2. Create bdump, udump & cdump directories

Create bdump, udump & cdump directories as specified in the pfile from the previous step.

3. Add a new entry to oratab, and source the environment
Edit the /etc/oratab and add an entry for the new database.

Set ORACLE_HOME and $ORACLE_SID as per the values of the new database

4. Create a password file

Use the following command to create a password file (add an appropriate password to the end of it):

orapwd file=${ORACLE_HOME}/dbs/orapw${ORACLE_SID} password=<your password>

5. Duplicate the database

From sqlplus, start the instance up in nomount mode:

startup nomount
Exit sqlplus, start RMAN and duplicate the database.

If no recovery catalog is available. :

rman target sys@<source_database> nocatalog auxiliary /

If recovery catalog is available. :

rman target sys@<source_database> catalog <rman user>/<rman user pwd>@<recovery catalog DB> auxiliary /

duplicate target database to <clone database name>;
This will restore the database and apply some archive logs.

6. Create an spfile

From sqlplus:

create spfile from pfile;

shutdown immediate
Now that the clone is built, we no longer need the file_name_convert settings:

alter system reset db_file_name_convert scope=spfile sid='*'

alter system reset log_file_name_convert scope=spfile sid='*'

7. Optionally take the clone database out of archive log mode

RMAN will leave the cloned database in archive log mode. If archive log mode isn't required, run the following commands from sqlplus:

shutdown immediate
startup mount
alter database noarchivelog;
alter database open;

8. Configure TNS

Add entries for new database in the listener.ora and tnsnames.ora as necessary, and start the listener

The following link illustrates a example to create a Duplicate Database using RMAN :