orawin.info

Niall's Oracle Pages – Oracle Opinion since 2004

In Praise of Clones

with 5 comments

I’m all alone, so are we all
We’re all clones
All are one and one are all

~ Alice Cooper

Two separate discussions, one at work and one around the virtual OakTable , have made me aware that maybe not as many Oracle professionals as I imagined are aware that Oracle provides a facility to clone Oracle Software homes, either to a new home on the same machine, or to a new home on a brand new machine with the same build. This process is far quicker than the graphical installation routine, or even than a straightforward silent install using OUI. It also lends itself very neatly to quickly provisioning identical builds of database servers. I thought therefore I’d jot down my notes on how I recently did just that for a data guard demo environment.

Servers Involved

I had 2 servers involved here, their setup is as follows:

Purpose Server Physical IP Address SID
Primary Server DB11-2-NODE1 192.168.56.11/24 db11gr2
Standby Server DB11-2-NODE2 192.168.56.11/24 db11g_stdby

The servers are both running my favourite RHEL clone CentOS, in this case the Release 5.6.

Initial Setup

After installing the O/S, updating the kernel for security patches I installed the following products in /u01/app/oracle/product/11.2.0/dbhome_1 on node1.

  • Oracle Database 11.2.0.2
  • Oracle July PSU (12419331 )

The above process took approximately 2 hours including media download and basic server documentation.

Gold Image

At this point I could have simply repeated the process on node 2. However cloning is much easier and repeatable.  First I made a Gold Image by running the following as root on node 1. /media/dsl/database/linux/11.2 is a mount point containing my gold images.

cd /u01/app/oracle/product/11.2.0/dbhome_1
tar -cpvzf /media/dsl/database/linux/11.2/db112023.tgz .

Cloning

On the second machine I also mounted my DSL as above and then ran the following script

./installOracle.sh /media/dsl/database/linux/11.2/db112023.tgz /u01/app/oracle/product/11.1.0/dbhome_1 /u01/app/oracle OracleHome1

where installOracle.sh reads as follows

#!/usr/bin/ksh
#
# Install gold image of Oracle using clone home functionality of OUI.
#
# Expects parameters <name of image> <install_loc> <Oracle Home Name>
# Assumes Pre-Reqs are met -- TODO add pre-req fixing
# assumes unzip installed
#
if [[ $# -ne 4 ]]; then
 echo "Usage : installOracle.sh imageName instLoc oracle_base HomeName";
 echo " : eg installOracle.sh /media/dbhome111.tgz /u01/app/oracle/product/11.1.0/db_1 /u01/app/oracle OracleHome11g"
 exit 1;
fi

IMAGE=$1
INSTLOC=$2
ORABASE=$3
HOMENAME=$4

echo "Making Oracle Home Directory"
mkdir -p ${INSTLOC}
chown -R oracle:oinstall ${ORABASE}
cd ${INSTLOC}
echo "Extracting Archive at $(date +%Y%M%d%m)"
tar -xvzf ${IMAGE}
cd clone/bin
echo "Cloning Home........."
sudo -u oracle perl clone.pl ORACLE_HOME="${INSTLOC}" ORACLE_HOME_NAME="${HOMENAME}" ORACLE_BASE="${ORABASE}" -ignoreSysPrereqs
${INSTLOC}/root.sh
echo "Install Finished at $(date +%Y%M%d%m)"
echo "Please run any non root.sh scripts as instructed above. root.sh has been run"

This code has to be run as root. It does the following

  • creates the home directory
  • extracts the gold image from the tarball
  • runs a perl script as the oracle user
  • runs root.sh

This script completed in less than 10 minutes on an identical virtual machine to the one that had taken 2 hours to perform the complete install and patching process.

Metalink Reference : How to clone an Oracle Database Home using OUI 

Possibly Related Posts:

  • No Related Posts found

Written by Niall Litchfield

July 27th, 2011 at 3:20 pm

Posted in Uncategorized

Tagged with , ,

5 Responses to 'In Praise of Clones'

Subscribe to comments with RSS or TrackBack to 'In Praise of Clones'.

  1. Excellent little trick there.

    I’m wondering, what if I want to include the database structures with this cloned image? I noticed, or assumed, that the database files weren’t included, is that true?

    What I would like to do, eventually, is build a continuous integration environment where the production database is cloned (with or without data, a choice I suppose that could be configured), then built on the fly, upgrade scripts run, tests run and test results published. Then have the entire environment destroyed (because I love to break stuff).

    chet

    31 Jul 11 at 11:27 pm

  2. Chet

    No you didn’t miss anything. This technique is useful for rolling out Oracle Home installations for the RDBMS. What you describe would probably be best achieved by using the template facility within dbca (which essentially produces an rman clone of a standardized source db).

    Niall Litchfield

    1 Aug 11 at 7:54 am

  3. Thank you sir. I’ll have to check that out.

    chet

    1 Aug 11 at 3:37 pm

  4. Hi Niall

    It might also be worth mentioning for the benefit of those RAC users unfamiliar with cloning that it’s possible to clone the clusterware too:

    http://download.oracle.com/docs/cd/E11882_01/rac.112/e16794/clonecluster.htm#CWADD03202

    Austin Hackett

    5 Aug 11 at 12:37 pm

  5. Hi Niall,

    Interesting Rakesh brought cloning up the other day. The same clone script is available in OFM homes, although there it is required to run the prepare_clone.pl scripts which does collect the files and mainly makes a backup of the DCM as well. Infrastructure and ssl configured Oracle Homes can apparently not be cloned.

    Bernhard Jongejan

    12 Aug 11 at 4:55 pm

Leave a Reply

%d bloggers like this: