Steps to Clone an Oracle Database Instance

This procedure documents the steps to follow when cloning (making an exact copy without using the export/import utilities) an Oracle database instance. It should take around 30 minutes to complete if properly done and you know where you are going to place the files.

  1. Create OFA-compliant directory structure for your new DBMS. Consult The OFA Standard – Oracle7 for Open Systems white paper by Cary V. Millsap dated 24 Sep 1995 for OFA information.
  2. Login to your DBMS server as the ORACLE user.
  3. Set your ORACLE_SID and ORACLE_HOME environment variables to the correct settings for the database instance of the database you wish to clone.
  4. Start SVRMGRL and issue the following commands:
  5. connect internal
    alter database backup controlfile to trace;
    exit;

    This creates a trace file in the OFA udump directory named SID_ora_######.trc where ##### is the PID of the process that created the trace file.

  6. Copy the SID_ora_######.trc file to the OFA create directory for your CLONED database and rename it to cloneSID.sql. You will be editing it later. It should look like:
  7. Dump file /oracle/dbs/app/oracle/admin/SEED/udump/seed_ora_24583.trc
    Oracle7 Server Release 7.3.3.5.0 - Production Release
    With the distributed option
    PL/SQL Release 2.3.3.5.0 - Production
    ORACLE_HOME = /oracle/dbs/app/oracle/product/7.3.3
    System name:	SunOS
    Node name:	redwood
    Release:	5.5.1
    Version:	Generic_103640-12
    Machine:	sun4u
    Instance name: SEED
    Redo thread mounted by this instance: 1
    Oracle process number: 7
    Unix process pid: 24583, image: oracle
    
    Wed Nov 25 09:14:59 1998
    Wed Nov 25 09:14:59 1998
    *** SESSION ID:(6.1) 1998.11.25.09.14.59.000
    # The following commands will create a new control file and use it
    # to open the database.
    # No data other than log history will be lost. Additional logs may
    # be required for media recovery of offline data files. Use this
    # only if the current version of all online logs are available.
    STARTUP NOMOUNT
    CREATE CONTROLFILE REUSE DATABASE "SEED" NORESETLOGS NOARCHIVELOG
        MAXLOGFILES 32
        MAXLOGMEMBERS 2
        MAXDATAFILES 30
        MAXINSTANCES 8
        MAXLOGHISTORY 800
    LOGFILE
      GROUP 1 '/export/home/oradata/SEED/redoSEED01.log'  SIZE 500K,
      GROUP 2 '/d13/oradata/SEED/redoSEED02.log'  SIZE 500K,
      GROUP 3 '/d14/oradata/SEED/redoSEED03.log'  SIZE 500K
    DATAFILE
      '/export/home/oradata/SEED/system01.dbf',
      '/export/home/oradata/SEED/rbs01.dbf',
      '/export/home/oradata/SEED/temp01.dbf',
      '/export/home/oradata/SEED/tools01.dbf',
      '/export/home/oradata/SEED/users01.dbf',
      '/oradata/SEED/development.dbf',
      '/oradata/SEED/system02.dbf',
      '/oradata/SEED/temp02.dbf',
      '/oradata/SEED/tools02.dbf',
      '/oradata/SEED/system03.dbf',
      '/oradata/SEED/rbs02.dbf'
    ;
    # Recovery is required if any of the datafiles are restored backups,
    # or if the last shutdown was not normal or immediate.
    RECOVER DATABASE
    # Database can now be opened normally.
    ALTER DATABASE OPEN;
    
    
  8. Shutdown the database you wish to clone and perform a COLD backup – better safe than sorry!!!
  9. COPY all the datafiles, logfiles, initSID.ora, and configSID.ora files used by the current database to the locations to be used by the new (CLONED) database. Remember to use OFA-compliant names for each file.
  10. Re-start the database you are cloning – others may wish to access it.
  11. Edit the initSID.ora and configSID.ora files for the cloned database and be sure to change the database name and control file locations to point to the CLONED database directories. DO NOT ALLOW ANY SETTINGS TO ACCESS THE DATABASE YOU ARE CLONING FROM! DOUBLE CHECK YOUR WORK!
  12. Edit the oratab file and create an entry for the clone dbms.
  13. Edit the oraenv script to make sure the environment settings are correct. SCT Banner users should edit the banenv script to configure Banner environment variables for the new instance.
  14. Make the following changes to the cloneSID.sql script:
  1. delete all lines above the CREATE CONTROLFILE … line.
  2. Change REUSE to SET on the CREATE CONTROLFILE … line.
  3. Change the SID to the new SID you are using for the CLONED database.
  4. Change NORESETLOGS to RESETLOGS on the CREATE CONTROLFILE … line.
  5. Remove ALL COMMENTS (lines that begin with #)
  6. Add RESETLOGS to the ALTER DATABASE OPEN line.
  7. Change the LOGFILE(s) names/locations under the LOGFILE line to reflect the locations/names of the logfile(s) copied in step #7.
  8. Change the DATAFILE(s) names/locations under the DATAFILE line to reflect the location/names of the files copied in step #7.
  9. Make sure the NOARCHIVELOG option is changed to ARCHIVELOG if you are using log archiving on the cloned dbms.
Your changes should look like the following:
CREATE CONTROLFILE SET DATABASE "CLONE" RESETLOGS NOARCHIVELOG
    MAXLOGFILES 32
    MAXLOGMEMBERS 2
    MAXDATAFILES 30
    MAXINSTANCES 8
    MAXLOGHISTORY 800
LOGFILE
  GROUP 1 '/export/home/oradata/CLONE/redoSEED01.log'  SIZE 500K,
  GROUP 2 '/d13/oradata/CLONE/redoSEED02.log'  SIZE 500K,
  GROUP 3 '/d14/oradata/CLONE/redoSEED03.log'  SIZE 500K
DATAFILE
  '/export/home/oradata/CLONE/system01.dbf',
  '/export/home/oradata/CLONE/rbs01.dbf',
  '/export/home/oradata/CLONE/temp01.dbf',
  '/export/home/oradata/CLONE/tools01.dbf',
  '/export/home/oradata/CLONE/users01.dbf',
  '/oradata/CLONE/development.dbf',
  '/oradata/CLONE/system02.dbf',
  '/oradata/CLONE/temp02.dbf',
  '/oradata/CLONE/tools02.dbf',
  '/oradata/CLONE/system03.dbf',
  '/oradata/CLONE/rbs02.dbf'
;
ALTER DATABASE OPEN RESETLOGS

  1. Set the ORACLE_SID and ORACLE_HOME environment variables to the correct settings for your new CLONED database.
  2. Position yourself to the OFA create directory where the cloneSID.sql script is located.
  3. Start SVRMGRL and issue the following commands:

  4. connect internal
    startup nomount;
    @cloneSID.sql;
    shutdown;
    startup;
    quit;

  5. Add entries to the tnsnames and listener file to allow SQL-net access if desired.

CONGRATULATIONS!!! – YOU’RE DONE!!!!