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 184.108.40.206.6 Oracle Interim Patch Installer version 220.127.116.11.6 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 : 18.104.22.168.6 OUI version : 22.214.171.124.0 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 126.96.36.199.0 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
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 *.log *.dbf ./network/admin/listener.ora ./network/admin/sqlnet.ora ./network/admin/tnsnames.ora ./oelinux.local_domain_ora11gr2 ./oc4j/j2ee/OC4J_DBConsole_oelinux.localdomain_ora11gr2 ./bin/nmo ./bin/nmb ./bin/nmhs [oracle@oelinux ~]$
Note for Database 11g: Permissions are more restrictive for the files
$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 root.sh 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_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 root.sh 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
INVENTORY_LOCATION and the
ORACLE_HOME is the directory structure in which you uncompressed the archive. In this example that path is
INVENTORY_LOCATION is the path to the oraInventory location. This must match the inventory_loc value in
[oracle@newhost dbhome_1]$ cat oraInst.loc inventory_loc=/u01/app/oraInventory inst_group=oinstall [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_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 188.8.131.52.0 Production Copyright (C) 1999, 2009, Oracle. All rights reserved. You can find the log of this install session at: /u01/app/oraInventory/logs/cloneActions2011-06-28_12-42-02PM.log .................................................................................................... 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/orainstRoot.sh' 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. /u01/app/oraInventory/orainstRoot.sh /u01/app/oracle/product/11.2.0/dbhome_1/root.sh 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 - Password: [root@newhost ~]# /u01/app/oraInventory/orainstRoot.sh 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/root.sh 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 Logout [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@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]$