Cloning an Oracle Database Home

by Eric Jenkinson on June 28, 2011

Categories: Oracle Database

Tagged: , ,

Starting with Oracle Database 10g you are able to easily clone an existing Oracle Home. Why would you want to be able to do this? For one it is faster to clone an existing Oracle install than to install fresh. The clone includes all patches that might have been installed thus removing the problem of missing patches when building a new server.

This document will detail the steps to clone an existing Oracle 11gR2 Enterprise Database home on Oracle Enterprise Linux but the steps will work with 10g and above on supported Linux/Unix platforms.

First we need to insure that the install we are going to use for the clone was installed successfully. Installation logs are located in $ORACLE_BASE/oraInventory/logs. Installation logs have format installActionsDATE_TIME.log. Look for something similar to the following to validate a successful install.

INFO: Since operation was successful, move the current OiicAPISessionDetails to installed list
INFO: Number of root scripts to be executed = 2
INFO: isSuccessfullInstallation: true
INFO: isSuccessfullRemoteInstallation: true
INFO: Adding ExitStatus SUCCESS to the exit status set
INFO: Completed setting up InstallDB
INFO: Performing Configuration

Depending on the installation method, this section could be more towards the end of the file or more towards the middle if a database was created during the installation.

Next we need to validate any patches that might have been installed along with their status using OPatch.

[oracle@oelinux ~]$ $ORACLE_HOME/OPatch/opatch lsinventory
Invoking OPatch

Oracle Interim Patch Installer version
Copyright (c) 2009, Oracle Corporation.  All rights reserved.

Oracle Home       : /u01/app/oracle/product/11.2.0/dbhome_1
Central Inventory : /u01/app/oraInventory
   from           : /etc/oraInst.loc
OPatch version    :
OUI version       :
OUI location      : /u01/app/oracle/product/11.2.0/dbhome_1/oui
Log file location : /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2011-06-23_13-37-32PM.log

Patch history file: /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch_history.txt

Lsinventory Output file location : /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/lsinv/lsinventory2011-06-23_13-37-32PM.txt

Installed Top-level Products (1): 

Oracle Database 11g                                        
There are 1 products installed in this Oracle Home.

There are no Interim patches installed in this Oracle Home.


OPatch succeeded.
[oracle@oelinux ~]$

OPatch reports that there is only one product installed in the Oracle Home and that there are no interim patched applied.

Now we need to package the Oracle Home. When creating the tar package of the Oracle Home be sure to exclude the following files and directories.

– Data Files
– Log Files
– $ORACLE_HOME/network/admin/listener.ora
– $ORACLE_HOME/network/admin/tnsnames.ora
– $ORACLE_HOME/network/admin/sqlnet.ora
– $ORACLE_HOME/oc4j/j2ee/OC4J_DBConsole__

You also want to exclude the admin/diag, flash recovery area and oradata directories if they are stored in the Oracle Home. Exclusions listed in an exclude file can be passed to the tar command. Below are the contents of the exclude file used in this example.

[oracle@oelinux ~]$ cat excludes.txt 

[oracle@oelinux ~]$

Note for Database 11g: Permissions are more restrictive for the files $ORACLE_HOME/bin/nmo, $ORACLE_HOME/bin/nmb and $ORACLE_HOME/bin/nmhs. When you attempt to tar these files, tar will report permission denied. For 11g and higher these files should be added to the exclusion list. These files will be recreated by the execution of the script executed later in the clone process.
Change directory to $ORACLE_HOME and create a tar archive using the excluded files list.

[oracle@oelinux ~]$ cd /u01/app/oracle/product/11.2.0/dbhome_1
[oracle@oelinux dbhome_1]$ tar -zcvf ~/orahome11gR2_lin32.tar.gz . -X ~/excludefiles.txt > ~/clonelog.txt
[oracle@oelinux dbhome_1]$ 

Next we need to transfer the archive to the new host. Keep in mind that host that will receive the cloned Oracle Home will need to have the same configuration and packages installed just as like a traditional install. Create the Oracle Home directory structure and set the ORACLE_BASE and ORACLE_HOME environment variables. Copy the archive to the ORACLE_HOME directory and uncompress.

[oracle@newhost ~]$ mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1
[oracle@newhost ~]$ export ORACLE_BASE=/u01/app
[oracle@newhost ~]$ export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
[oracle@newhost ~]$ cd $ORACLE_HOME/
[oracle@newhost dbhome_1]$ cp ~/orahome11gR2_lin32.tar.gz .
[oracle@newhost dbhome_1]$ tar -xvf orahome11gR2_lin32.tar.gz

Once uncompressing the archive is complete all of the binaries are in place.

[oracle@newhost dbhome_1]$ ls
apex         emcli                mesg                       precomp
assistants   EMStagePatches_orcl  mgw                        racg
bin          has                  network                    rdbms
ccr          hs                   nls                        relnotes
cdata        ide                  oc4j             
cfgtoollogs  install              odbc                       scheduler
clone        install.platform     olap                       slax
config       instantclient        ons                        sqldeveloper
crs          inventory            OPatch                     sqlj
csmig        j2ee                 opmn                       sqlplus
css          javavm               oracore                    srvm
ctx          jdbc                 orahome11gR2_lin32.tar.gz  sysman
cv           jdev                 oraInst.loc                timingframework
dbs          jdk                  ord                        ucp
dc_ocm       jlib                 oui                        uix
deinstall    ldap                 owb                        utl
demo         lib                  owm                        wwg
diagnostics  log                  perl                       xdk
dv           md                   plsql
[oracle@newhost dbhome_1]$

Now the Oracle Universal Install needs to be executed to clone the home. The Oracle Universal Installer will be ran in silent mode and passed the –clone operation. The clone operation requires four parameters: the ORACLE_HOME, ORACLE_BASE, the INVENTORY_LOCATION and the ORACLE_HOME_NMAE.

The ORACLE_HOME is the directory structure in which you uncompressed the archive. In this example that path is /u01/app/oracle/product/11.2.0/dbhome_1. The INVENTORY_LOCATION is the path to the oraInventory location. This must match the inventory_loc value in ORACLE_HOME/oraInst.loc.

[oracle@newhost dbhome_1]$ cat oraInst.loc 
[oracle@newhost dbhome_1]$

If you want to use another directory other then the directory pointed to by inventory_loc then change the value stored in ORACLE_HOME/oraInst.loc prior to running Oracle Universal Installer. In this example we leave the location as /u01/app/oraInventory. The oraInventory directory is generally stored in the ORACLE_BASE so for this example /u01/app will be passed as the ORACLE_BASE.

The ORACLE_HOME_NAME is the name to identify this Oracle Home. In this example ORACLE_HOME_NAME will be ‘OraHome11gR2’.

[oracle@newhost dbhome_1]$ $ORACLE_HOME/oui/bin/runInstaller -silent -clone ORACLE_HOME="/u01/app/oracle/product/11.2.0/dbhome_1" ORACLE_BASE="/u01/app" INVENTORY_LOCATION="/u01/app/oraInventory" ORACLE_HOME_NAME="OraHome11gR2"
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 4094 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2011-06-28_12-42-02PM. Please wait ...[oracle@newhost dbhome_1]$ Oracle Universal Installer, Version Production
Copyright (C) 1999, 2009, Oracle. All rights reserved.

You can find the log of this install session at:
.................................................................................................... 100% Done.

Installation in progress (Tuesday, June 28, 2011 12:42:29 PM PDT)
..............................................................................                                                  78% Done.
Install successful

Linking in progress (Tuesday, June 28, 2011 12:42:45 PM PDT)
Link successful

Setup in progress (Tuesday, June 28, 2011 12:45:31 PM PDT)
Setup successful

End of install phases.(Tuesday, June 28, 2011 12:48:36 PM PDT)
Starting to execute configuration assistants
Configuration assistant "Oracle Configuration Manager Clone" succeeded 
WARNING:A new inventory has been created in this session. However, it has not yet been registered as the central inventory of this system.
To register the new inventory please run the script '/u01/app/oraInventory/' with root privileges. 
If you do not register the inventory, you may not be able to update or patch the products you installed.
The following configuration scripts need to be executed as the "root" user.
To execute the configuration scripts:
    1. Open a terminal window
    2. Log in as "root"
    3. Run the scripts
The cloning of OraHome11gR2 was successful.
Please check '/u01/app/oraInventory/logs/cloneActions2011-06-28_12-42-02PM.log' for more details.

[oracle@newhost dbhome_1]$ 

To complete the clone the root scripts need to executed as the root user.

[oracle@newhost dbhome_1]$ su -
[root@newhost ~]# /u01/app/oraInventory/ 
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
[root@newhost ~]# /u01/app/oracle/product/11.2.0/dbhome_1/
Check /u01/app/oracle/product/11.2.0/dbhome_1/install/root_newhost.oracledistlled.com_2011-06-28_13-00-26.log for the output of root script
[root@newhost ~]# exit
[oracle@newhost dbhome_1]$

This completes the process of cloning an existing Oracle Home to a new server. If you are using 11g as in this example you can verify that the process recreated the nmb, nmo and nmhs files that were excluded from $ORACLE_HOME/bin

[oracle@newhost ~]$ cd $ORACLE_HOME/bin
[oracle@newhost bin]$ ls -al nm*
-rws--x--- 1 root   oinstall 27859 Jun 28 12:43 nmb
-rwxr-xr-x 1 oracle oinstall     0 Aug 13  2009 nmb0
-rwxr-xr-x 1 oracle oinstall 27859 Jun 28 12:43 nmb.0
-rwxr-xr-x 1 oracle oinstall  9755 Aug  7  2009 nmcbufp
-rwxr-xr-x 1 oracle oinstall 69539 Jun 28 12:43 nmei
-rwxr-xr-x 1 oracle oinstall 69539 Jun 27 15:20 nmei0
-rws--x--- 1 root   oinstall 80325 Jun 28 12:43 nmhs
-rwxr-xr-x 1 oracle oinstall     0 Aug 13  2009 nmhs0
-rwxr-xr-x 1 oracle oinstall 80325 Jun 28 12:43 nmhs.0
-rws--x--- 1 root   oinstall 34567 Jun 28 12:43 nmo
-rwxr-xr-x 1 oracle oinstall     0 Aug 13  2009 nmo0
-rwxr-xr-x 1 oracle oinstall 34567 Jun 28 12:43 nmo.0
-rwxr-xr-x 1 oracle oinstall 32389 Jun 28 12:43 nmocat
-rwxr-xr-x 1 oracle oinstall 32389 Jun 27 15:20 nmocat0
-rwxr-xr-x 1 oracle oinstall 55334 Jun 28 12:43 nmosudo
-rwxr-xr-x 1 oracle oinstall 55334 Jun 27 15:20 nmosudo0
-rwxr-xr-x 1 oracle oinstall 21342 Jun 28 12:43 nmupm
-rwxr-xr-x 1 oracle oinstall 21342 Jun 27 15:20 nmupm0
[oracle@newhost bin]$


  • Venkat (August 29, 2012 9:04 am)

    The point “Note for Database 11g: Permissions are more restrictive for the files $ORACLE_HOME/bin/nmo, $ORACLE_HOME/bin/nmb and $ORACLE_HOME/bin/nmhs.”
    really helped me… Thanks for article..

    May know the Metalink doc ID for above point.

  • Eric Jenkinson (September 7, 2012 12:04 pm)

    Hello Venkat,

    I am happy you found something useful in the post. Please see Oracle Support Note: 1198163.1 Cloning of Database Oracle_Home using Grid Control Failing With Permission Denied.

    Thank you for visiting Oracle Distilled

  • Jatin (November 15, 2012 11:29 pm)

    Good work helped me was struggling for 3 hours

  • zul (April 13, 2013 7:55 pm)


  • Tabita (December 3, 2013 8:33 am)

    Thank you for fruitful information.
    I am working on RAC Exadata machine, I now need to create the database.
    Kindly help with the steps and information.

    Thanking you in advance

Post A Comment