Tuesday, January 27, 2009

Clone ORACLE_HOME

For a single-node Oracle install it is usually faster to clone the ORACLE_HOME than to re-install and re-apply patches.
Cloning can be done using OEM or manually using clone.pl or runInstaller
Cloning guarantees that you have identical components installed on DEV, QA, PROD.
You can only clone between the same OS - e.g. from AIX to AIX.
It is possible to clone the ASM and DB ORACLE_HOME but not the OEM agent.

The process I followed to manually clone on AIX is as follows. You can find more information in Metalink Note 565009.1.

#1. prepare for cloning (this step currently does not do anything useful but it may be necessary in the future)
cd $ORACLE_HOME/clone/bin
chmod u+x prepare_clone.pl
vi prepare_clone.pl
change /usr/local/bin/perl to /usr/bin/perl
prepare_clone.pl

#2. copy all files under $ORACLE_HOME to the destination directory or destination server (e.g use tar/ftp or scp).

#3. run the clone process (create new inventory or register the ORACLE_HOME with existing inventory, relink binaries etc)
# check the contents of /etc/oraInst.loc
more /etc/oraInst.loc
cd $ORACLE_HOME/clone/bin
chmod u+x clone.pl
vi clone.pl
change /usr/local/bin/perl to /usr/bin/perl
# example clone the ASM ORACLE_HOME (clone.pl calls oui)
perl clone.pl ORACLE_HOME="/opt/oracle/product/10.2.0/asm" ORACLE_HOME_NAME="ASM_HOME"
# example clone the DB ORACLE_HOME
perl clone.pl ORACLE_HOME="/opt/oracle/product/10.2.0/db_1" ORACLE_HOME_NAME="db10g_home1"
# check the inventory to confirm the ORACLE_HOME is registered
more /opt/oracle/product/oraInventory/ContentsXML/inventory.xml

# 11gr2 requires the ORACLE_BASE parameter
perl clone.pl ORACLE_BASE="/opt/oracle" ORACLE_HOME="/opt/oracle/product/11.2.0/dbhome_1" ORACLE_HOME_NAME="db112_home1"

#4. run root.sh in each ORACLE_HOME

#5. for the ASM ORACLE_HOME ask the unix team to run the following as root to setup the cluster software
cd $ORACLE_HOME/bin
localconfig delete
localconfig add

# if you have problems cloning with clone.pl you can directly call runInstaller but you do need an Xterm or VNC GUI session.

./runInstaller -clone ORACLE_HOME="/opt/oracle/product/10.2.0/owb" ORACLE_HOME_NAME="owb10g_home1"

# To clone a RAC 11g Home :-

export DISPLAY=xxx.xxx.xxx.xxx:0

ORACLE_BASE=/opt/oracle
ORACLE_HOME=/opt/oracle/product/11.1.0/db_1
cd $ORACLE_HOME/clone
THISNODE=`hostname -s`
E01=ORACLE_HOME=${ORACLE_HOME}
E02=ORACLE_HOME_NAME=11g_home1
E03=ORACLE_BASE=/opt/oracle
C01="-O'CLUSTER_NODES={q-prod-oranode-30, x-prod-oranode-31}'"
C02="-O'LOCAL_NODE=$THISNODE'"

perl $ORACLE_HOME/clone/bin/clone.pl $E01 $E02 $E03 $C01 $C02

# Or manually run runInstaller :-

./runInstaller -silent -clone -waitForCompletion ORACLE_HOME="/opt/oracle/product/11.1.0/db_1" ORACLE_HOME_NAME="11g_home1" ORACLE_BASE="/opt/oracle/product" "CLUSTER_NODES={q-prod-oranode-30, x-prod-oranode-31}" LOCAL_NODE="q-prod-oranode-30" -noConfig -nowait