RMAN Duplicate

Steps to clone a database using RMAN:
1: Create a password file on the destination server
2: Establish connectivity between the target and destination server (tnsnames.ora, sqlnet.ora)
3: Create the directories for the database files
4: Take the RMAN backup from the target server and copy it to the destination server.
5: Startup the destination database in nomount mode

6: Run the RMAN duplicate database command

Duplicating database with RMAN
Step 1 - Create a password file for the auxiliary instance or Copy from Primary Database
orapwd file=$ORACLE_HOME/dbs/orapwaux password=test entries=3;
Step 2 - Configure auxiliary instance listener net configuration
LISTENER.ORA #auxiliary instance 
    (SID_DESC =
      (SID_NAME = aux)
      (ORACLE_HOME = /u01/oracle/product/10.2.0/db_1)
    )

lsnrctl reload

note: edit the TNSNAMES.ORA file at the production database and add the entry about auxiliary database to it as follows:
AUX =
  (DESCRIPTION =
    (ADDRESS_LIST =
       (ADDRESS=(PROTOCOL=TCP)(HOST= DUP_SERVER)(PORT=1521))
    )
    (CONNECT_DATA=
      (ORACLE_SID=aux)
    )
   )

tnsping aux

Step 3 - Create a parameter file for an Auxiliary database
note: you can copy fom primary and check the following
DB_NAME
CONTROL_FILES
DB_BLOCK_SIZE
COMPATIBLE
SGA_TARGET
and create directory for:
adump
bdump
udump
cdump
Flash Recovery Area

$ export ORACLE_SID=aux
$ export ORACLE_HOME=/u01/oracle/product/10.2.0/db_1/
$ sqlplus "/ as sysdba"

CREATE SPFILE FROM  PFILE='/u01/oracle/product/10.2.0/db_1/dbs/pfile.ora';

Step 4 - Startup auxiliary instance in NOMOUNT mode
STARTUP NOMOUNT

Step 5 - Backup the production database and copy all backup files to auxiliary server
$ export ORACLE_SID=db1
$ rman target /
RMAN> BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG;

Step 6 - Create datafile locations on an auxiliary server

Step 7 - Copy the backup of the production database to the same directory residing on the auxiliary database server

Step 8 - Duplicate the Database
rman target sys/my_pass auxiliary sys/test@aux

DUPLICATE TARGET DATABASE TO aux NOFILENAMECHECK;
note: Generates a new unique DBID for the clone database 

other E.G 
rman target sys/oracle01@PRDVITAL auxiliary sys/oracle01@PRDVITAL_STBY1
se pasan los parametros db_unique_name,log_archive_dest_2,log_archive_dest_3,fal_server,control_files


duplicate target database for standby from active database 
dorecover 
spfile
set db_unique_name='prdvital_stby1' COMMENT 'stby1'
set fal_server='prdvital','prdvital_stby2' COMMENT 'Stby1'
set log_archive_dest_2='SERVICE=prdvital ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=prdvital'
set log_archive_dest_3='service="prdvital_stby2"','LGWR ASYNC NOAFFIRM delay=0 optional compression=disable max_failure=0 max_connections=1 reopen=300 db_unique_name="prdvital_stby2" net_timeout=30','valid_for=(all_logfiles,primary_role)'
set control_files='+DATA','+FRA' comment 'Controlfile Multiplexado'
nofilenamecheck;