Duplicate a Database Using RMAN in Oracle 19c
Preconditions & Assumptions
- Source DB:
ORCL(running and reachable over network). - Target DB (clone host):
CLONE(OS user, Oracle software installed). - Network connectivity and valid
tnsnames.ora/ listener entries on both hosts. - You have
SYSDBAcredentials on source and auxiliary (clone). - Source database is backed up or accessible for network backups by RMAN (active duplication uses online data).
- Adequate disk space on target for datafiles, redo, controlfiles, FRA, and temp.
- Password file is copied to the target if needed for remote SYS connections.
- PFILE for target is prepared with
db_nameanddb_file_name_convert/log_file_name_convertconfigured. - You understand implications of
RESETLOGSthat RMAN may perform during duplicate.
High-level flow
- Copy password file and PFILE/SPFILE (or create PFILE from source SPFILE).
- Configure target pfile with
db_nameand*_file_name_convertentries. - Prepare target directories and environment; start target instance NOMOUNT with PFILE.
- Ensure listeners and TNS entries allow RMAN to connect to the source from the target.
- Run RMAN
DUPLICATE DATABASE TO 'clone' FROM ACTIVE DATABASE NOFILENAMECHECKfrom the clone host (auxiliary). - RMAN creates control files, restores datafiles, applies logs, creates controlfile for clone, and opens clone database.
- Verify clone and perform post-duplicate housekeeping (backups, listeners, archive destinations, etc.).
Detailed step-by-step (copy-paste friendly)
Source host =
orcl.localdomain.com(ORCL)
Target host =clone.localdomain.com(CLONE)
Modify all paths, hostnames, SIDs and environment variables to match your infrastructure.
SOURCE: copy password file and create PFILE
- Copy the password file from source to target (so RMAN can connect to the auxiliary instance as SYS):
# on SOURCE as oracle OS user
scp $ORACLE_HOME/dbs/orapworcl oracle@clone:$ORACLE_HOME/dbs/orapwclone
- Create a PFILE from the source SPFILE (so you can edit DB_NAME and file name convert entries for the target):
-- on SOURCE as SYS
SQL> SHOW PARAMETER spfile;
SQL> CREATE PFILE FROM SPFILE;
-- copy the created init<orcl>.ora to the target and rename to initclone.ora
scp $ORACLE_HOME/dbs/initorcl.ora oracle@clone:$ORACLE_HOME/dbs/initclone.ora
TARGET: prepare directories, pfile and environment
- Create required directories on the target:
# on TARGET as oracle
mkdir -p /oradb/app/oracle/admin/clone/adump
mkdir -p /oradb/app/oracle/oradata/clone
mkdir -p /oradb/app/oracle/oradata/clone/controlfile
mkdir -p /oradb/app/oracle/oradata/clone/onlinelog
mkdir -p /oradb/app/oracle/oradata/clone/datafile
- Edit
initclone.ora(PFILE) — changedb_name, and add convert parameters:
# initclone.ora (example entries to add/change)
*.audit_file_dest='/oradb/app/oracle/admin/clone/adump'
*.db_file_name_convert='/oradb/app/oracle/oradata/orcl','/oradb/app/oracle/oradata/clone'
*.log_file_name_convert='/oradb/app/oracle/oradata/orcl','/oradb/app/oracle/oradata/clone'
*.control_files='/oradb/app/oracle/oradata/clone/control01.ctl','/oradb/app/oracle/oradata/clone/control02.ctl'
*.db_name='clone'
- Configure target Oracle environment (example function to source in shell):
# set environment for CLONE (example)
export ORACLE_HOME=/oradb/app/oracle/product/19.0.0/db_1
export ORACLE_BASE=/oradb/app/oracle
export ORACLE_SID=clone
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:.
- Start the target instance in NOMOUNT using the modified PFILE:
# on TARGET as oracle
sqlplus / as sysdba
SQL> STARTUP PFILE='$ORACLE_HOME/dbs/initclone.ora' NOMOUNT;
NETWORK: listener and tnsnames configuration
- Ensure both source and target listeners are configured and running; ensure
tnsnames.oraentries on both sides. Example entries:
listener.ora (on source and target — adjust HOST):
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = orcl.localdomain.com)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
tnsnames.ora example:
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = orcl.localdomain.com)(PORT = 1521))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl.localdomain.com))
)
CLONE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = clone.localdomain.com)(PORT = 1521))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = clone.localdomain.com))
)
Start/listen and verify tnsping from target to source.
RMAN: Active duplication (NOFILENAMECHECK and name conversion)
- From the target (clone) host, run RMAN and connect to both the source(target) and auxiliary (clone) instances:
# on TARGET
rman target sys/oracle@orcl auxiliary sys/oracle
- Execute the active duplicate command:
RMAN> DUPLICATE DATABASE TO 'clone' FROM ACTIVE DATABASE NOFILENAMECHECK;
Notes on parameters:
FROM ACTIVE DATABASEinstructs RMAN to read the source’s datafiles over the network (no backup sets required).NOFILENAMECHECKallows RMAN to retain file names; if environments are on different hosts you frequently needNOFILENAMECHECK.- Use
DB_FILE_NAME_CONVERTandLOG_FILE_NAME_CONVERTparameters in PFILE orSET NEWNAMERMAN commands to control target file names and locations.
Representative RMAN transcript (abridged)
RMAN will: create an SPFILE on clone from memory, restart the clone instance, restore a control file from the source, mount the clone, set NEWNAME for each datafile, restore datafiles, restore archived logs, recover to a SCN or until current, create controlfile for CLONE, switch datafile copies, and open the database RESETLOGS. Example transcript excerpts (abridged) from a lab run are included inline in the previous section of this article—retain for auditing.
Post-duplicate verification
Run these checks on the clone:
-- On CLONE
SQL> SELECT name, open_mode FROM v$database;
-- Verify controlfile and datafiles
SQL> SELECT name FROM v$controlfile;
SQL> SELECT file_name, tablespace_name FROM dba_data_files;
-- Check that services and listeners are correct
lsnrctl status
-- Check alert log for completion messages and any errors
tail -100 $ORACLE_BASE/diag/rdbms/clone/trace/alert_clone.log
Sample expected output:
NAME OPEN_MODE
----- ----------
CLONE READ WRITE
Cleanup & mandatory actions
- Reset DB_NAME & DB_UNIQUE_NAME: RMAN duplicates typically adjust these during the process. Confirm
DB_NAMEandDB_UNIQUE_NAMEare correct for CLONE. - Listener/TNS: ensure CLONE listener is active and service registered.
- Archive / FRA: verify archive destinations, FRA size and config on clone.
- Backups: take a full RMAN backup of the clone after duplication and before putting clone into production.
- Network/security: rotate any passwords or keys if needed and remove copied password files if not required.
- Database identifiers: update any monitoring, backups, or management tooling to reference the new clone SID and DB_UNIQUE_NAME.
Troubleshooting common issues
- RMAN cannot connect to source service: verify
tnsnames.ora, listener services, and network reachability (ping, tnsping). - Insufficient disk space: duplication will fail if target file systems are full — validate free space prior to running.
- Permissions errors when creating files: ensure Oracle OS user owns target directories and permissions allow Oracle to create files.
- Controlfile restore failures: if RMAN cannot restore controlfile from service, ensure source is reachable and that SYS credentials are valid.
- Mismatched character sets or endian issues: duplication across platforms of differing endian or incompatible charsets requires additional considerations — review Oracle documentation before cross-platform duplicates.
- NOFILENAMECHECK misuse: be cautious —
NOFILENAMECHECKcan cause unintended overwrites if target and source share storage paths; validatedb_file_name_convertcarefully.
Best practices & recommendations
- Test the duplicate procedure in a non-production environment before first run.
- Maintain adequate network throughput between source and target (active duplication is network intensive).
- Keep password file and PFILE/SPFILE handling secure — do not leave copies with weak permissions.
- Automate pre-checks (space, listener status, tnsnames) as part of a duplication script to reduce human error.
- Immediately backup the cloned database (RMAN backup) after duplication to establish a recovery baseline.
- Document the clone operation (timestamp, RMAN commands used, any special parameters, and post-checks).
Short checklist (run before executing)
- Confirm source DB is fully available and stable.
- Copy password file to target.
- Create & edit PFILE for clone (db_name, file convert parameters).
- Create directories and verify permissions on target.
- Ensure listeners and network connectivity are validated.
- Confirm sufficient free space on target.
- Prepare RMAN credentials for source and auxiliary.
- Schedule maintenance window (if required).
No Comments