Oracle: rman duplicateΒΆ

Title:Oracle: rman duplicate
Author:Douglas O’Leary <>
Description:Oracle: rman duplicate
Date created:08/09/2010
Date updated:08/09/2010
Disclaimer:Standard: Use the information that follows at your own risk. If you screw up a system, don’t blame it on me...

Rman has a duplicate database command that does most of the tasks for duplicating a database. There are some serious gotchas waiting for the unwary, though. For the purposes of this doc: oci1 is the source database, oci3 is the target/auxiliary database. From here on out, I will call the target database auxiliary to avoid confusion with the “rman target” syntax.

Here is the process, beginning to end, for duplicating a database on the same host:

  1. Create the directory structure for the auxiliary database:

    cd /oracle/admin # or wherever the admin dir for your set up is
    find oci1 -type d -print | sed 's/oci1/oci3/g' | \
        xargs -i mkdir -p -m 755 {}
  2. Create a pwd file for the auxiliary instance:

    cd /oracle/product/10.2.0/db_1/dbs # or wherever your pwd files are orapwd file=orapwoci3 password=${mypwd} entries 20

  3. Create an init.ora file for the auxiliary instance:

    cd /oracle/product/10.2.0/db_1/dbs # or wherever pfiles default to
    vi initoci3.ora # add these entries:
    1. *.db_name=’oci3’ # gives the auxiliary database its name.
    2. db_file_name_convert=(‘oci1’, ‘oci3’) # converts datafile locations, /oracle/oradata/oci1 becomes /oracle/oradata/oci3.
    3. log_file_name_convert = (‘/oracle/oradata/oci1’, ‘/oracle/oradata/oci3’) # converts redo log locations in the same way.
    4. COMPATIBLE= # compatibility defaults to; controlfile creation at the end of the process will fail if there’s a mismatch
  4. Configure the listener: rman requires a dedicated server connection to both the source and auxiliary databases. The problem is that the listener will report oci3 as blocked when it’s in NOMOUNT mode.

    export ORACLE_SID=oci1;
    rman target / catalog rcat/${mypwd}@oci2 auxiliary sys/${mypwd}@oci3

    will fail even after setting up the dedicated server and starting oci3 in NOMOUNT mode because oci3 is not mounted. To circumvent this issue, you can either reverse which database is accessed locally, or update the listener.ora file with the oracle_home.

    rman target sys/${mypwd}@oci1 catalog=rcat/${mypwd}@oci3 auxiliary /

    OR create a dedicated server using netmgr for oci3 and update the listener.ora file, SID_LIST_LISTENER stanza with the following information:

    (SID_DESC =
      (GLOBAL_DBNAME = oci3)
      (ORACLE_HOME = /oracle/product/10.2.0/db_1)
      (SID_NAME = oci3)

    If you update the listener.ora, restart it.

  5. Startup nomount the database:

    export ORACLE_SID=oci3
    sqlplus / as sysdba
    startup nomount;
  6. Connect to rman:

    export ORACLE_SID=oci3;
    rman target sys/${mypwd}@oci1 catalog rcat/${mypwd}@oci2 auxiliary /
    # if using the alternate rman command
    export ORACLE_SID=oci1;
    rman target / catalog rcat/${mypwd}@oci2 auxiliary sys/${mypwd}@oci3
    # if you updated the listener
  7. duplicate target database to oci3

A few minutes later, you should have a nice shiney new clone of oci1. It’ll be readily apparent if it doesn’t work as rman errors are hard to miss.