The Application DBA  

Single Instance Oracle Home Cloning

Introduction

The following basic steps will be performed to clone the single instance database Oracle home.

  1. Create a new target directory.
  2. Un-tar the source Oracle home (i.e. gold copy) into the target directory.
  3. Update the oratab file.
  4. Run the Oracle clone.pl script to register the Oracle home.
  5. Verify the local and central inventories.
  6. Apply any required patches.

Create New Oracle Home

Create the new Oracle home and unarchive a gold copy or a "clean" source copy into the new directory (see Creating Gold Copies for Cloning).

As oracle:

cd /u01/app/oracle
mkdir -p product/11.2.0.3/db_1

Untar the source Oracle home into the target directories:

As root:

cd /u01/app/oracle/product/11.2.0.3/db_1
tar -zxvpf /orasrc/gold_copies/db11203.tgz .

Update the oratab file (optional)

Update the oratab file and add the new Oracle home. The new entry for this example should look like this:

*:/u01/app/oracle/product/11.2.0.3/db_1:N

Run Clone Utility

The following steps to run the clone.pl script should be done as oracle:

Set the environment to the new Oracle home:

Note: It’s easiest to add the new ORACLE_HOME to the oratab file and run orasetup to set the environment correctly.

$ . orasetup

or

$ export ORACLE_BASE=/u01/app/oracle
$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/db_1
$ export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch
$ export LD_LIBRARY_PATH=$ORACLE_HOME/lib

Run the clone.pl script:

To clone a single instance Oracle home all you need is the $ORACLE_BASE, $ORACLE_HOME and the ORACLE_HOME_NAME. The ORACLE_HOME_NAME must be unused or previously deleted and Oracle's default naming for 11g R2 seems to follow "OraDb11g_home<n>". The name can be anything you want and you can find the currently used names in the central inventory.

cd $ORACLE_HOME

perl $ORACLE_HOME/clone/bin/clone.pl ORACLE_BASE=$ORACLE_BASE
ORACLE_HOME=$ORACLE_HOME ORACLE_HOME_NAME="OraDb11g_home2"

Note: The script will ask you to run the root.sh script.

Check Inventory Files

To check the inventory files (i.e. local and central):

cat /u01/app/oraInventory/ContentsXML/inventory.xml
cat $ORACLE_HOME/inventory/ContentsXML/oraclehomeproperties.xml

Note: The central inventory file location can be found in the oraInst.loc file located in /etc on Linux.

The easiest way to verify that the central inventory has been properly updated is to run an opatch lsinventory command from the cloned Oracle home:

$ opatch lsinventory

Apply patches to the cloned Oracle home

Any patches can now be applied to the cloned Oracle home. The idea here is to save down time by performing all non-database specific tasks while the database(s) continue to run in their original Oracle home. If these patches will be the basis of a new gold copy then now is the time to create that copy.

Note: Any database required scripts that are included in the patches applied to the Oracle home that have not been previously run will need to be run once the database is switched to the cloned Oracle home.

References

Oracle® Database Installation Guide, 11g Release 2 (11.2) for Linux, Section B Cloning an Oracle Home

 

Copyright 1998-2013 AppsDBA Consulting. All Rights Reserved.