Clone an Oracle Home step by step

In this tutorial we will learn how to clone Oracle Home from one server to another. This task is performed in order for you to clone a database or move a database. You can do this just to skip a new install or if you want your Oracle binaries to be the same as in the source database.

We will work with a primary HOST and a TARGET host as the host that will receive the Oracle Home.

We will also assume that you already have oracle installed on the TARGET host on a different version(this is because of library needs), if you don't have one then you will need to install all the needed RPM's for an oracle installation.

  • 1- On the source HOST - Find the location of you Oracle Home:
  • HOST:>/home/oracle> . oraenv
    ORACLE_SID = [PER01] ? PER01
    The Oracle base for ORACLE_HOME=/l01/oracle/app/product/10.2.0/dbhome_1 is /l01/oracle/app
    
    HOST:/home/oracle> echo $ORACLE_HOME
    /l01/oracle/app/product/10.2.0/db_1
    
    #Start the copy process:
    
    HOST:/l01/oracle/app/product/10.2.0> scp -r dbhome_1/ TARGET:/u02/per01/app/10.2.0
    TARGET's password:
    
    portlist.ini                                                                                                        100%   33     0.0KB/s   00:00
    envVars.properties.bak                                                                                              100% 1100     1.1KB/s   00:00
    changePerm.sh                                                                                                       100%   11KB  11.5KB/s   00:00
    install.excl
     
  • 2- Next make sure that the oracle user has all the rights on the on the new copied binary files:
  •  TARGET# chown -R oraper01:oinstall db_1/
    
     
  • 3- Create an entry into your '/etc/oratab' file pointing to your new Oracle Home:
  • Make sure you know the path to the new Oracle Home and place it into your oratab files; in my case my

     #Backup file is  /u01/app/oragrd/product/11.2.0/grid/srvm/admin/oratab.bak.xxxx line added by Agent
    #
    
    
    
    # This file is used by ORACLE utilities.  It is created by root.sh
    # and updated by either Database Configuration Assistant while creating
    # a database or ASM Configuration Assistant while creating ASM instance.
    
    # A colon, ':', is used as the field terminator.  A new line terminates
    # the entry.  Lines beginning with a pound sign, '#', are comments.
    #
    # Entries are of the form:
    #   $ORACLE_SID:$ORACLE_HOME:<n|Y>:
    #
    # The first and second fields are the system identifier and home
    # directory of the database respectively.  The third filed indicates
    # to the dbstart utility that the database should , "Y", or should not,
    # "N", be brought up at system boot time.
    #
    # Multiple entries with the same $ORACLE_SID are not allowed.
    #
    #
    +ASM:/u01/app/oragrd/product/11.2.0/grid:N
    PRD:/u01/app/oraprd/product/11.2.0/db1:N
    #Add this line
    PER01:/u02/per01/app/10.2.0/db1:N
    
     
  • 4- Now from the TARGET host setup you enviroment variables and check the sqlplus utility:
  •  TARGET$ . oraenv
    ORACLE_SID = [PER01] ? PER01
    The /u02/per01/app/10.2.0/db1/bin/orabase binary does not exist
    You can set ORACLE_BASE manually if it is required.
    
    TARGET$ echo $ORACLE_HOME
    /u02/per01/app/10.2.0/db1
    TARGET$ echo $ORACLE_SID
    PER01
    TARGET$ sqlplus / as sysdba
    SQL*Plus: Release 10.2.0.5.0 - Production on Tue Dec 17 15:16:48 2013
    Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.
    
    Connected to an idle instance.
    
    SQL>
    
     

    Ok , so you can see that the ORACLE_HOME points to the newly copied binaries and the ORACLE_SID reflects our oratab file entry.

  • 5- Next will "clone" the new Oracle_Home.
  • Where the Oracle Home binaries will be linked and organized with the Linux libs.

    As options you will need to declare the ORACLE_HOME="The full pathe to the new Oracle Home" ORACLE_HOME_NAME="a unique name from the new Oracle Home" ORACLE_BASE="The full pathe to the new Oracle Base".

    TARGET# cd /u02/per01/app/10.2.0/db1/oui/bin/
    TARGET# ll
    total 296
    -rwxr-xr-x 1 oraper01 oinstall    168 Dec 17 15:39 addLangs.sh
    -rw-r--r-- 1 oraper01 oinstall    189 Dec 17 14:27 addLangs.sh.ouibak
    -rwxr-xr-x 1 oraper01 oinstall     88 Dec 17 15:39 addNode.sh
    -rw-r--r-- 1 oraper01 oinstall    102 Dec 17 14:27 addNode.sh.ouibak
    -rwxr-xr-x 1 oraper01 oinstall    276 Dec 17 15:39 attachHome.sh
    -rw-r--r-- 1 oraper01 oinstall    297 Dec 17 14:27 attachHome.sh.ouibak
    -rwxr-xr-x 1 oraper01 oinstall    183 Dec 17 15:39 detachHome.sh
    -rw-r--r-- 1 oraper01 oinstall    204 Dec 17 14:27 detachHome.sh.ouibak
    -rwxr-xr-x 1 oraper01 oinstall  51104 Dec 17 14:27 lsnodes
    -rwxr-xr-x 1 oraper01 oinstall    335 Dec 17 14:27 ouica.bat
    -rwxr-xr-x 1 oraper01 oinstall    453 Dec 17 15:39 ouica.sh
    -rw-r--r-- 1 oraper01 oinstall    551 Dec 17 14:27 ouica.sh.ouibak
    drwxr-x--- 2 oraper01 oinstall   4096 Dec 17 14:27 resource
    -rwxr-xr-x 1 oraper01 oinstall   1109 Dec 17 15:39 runConfig.sh
    -rw-r--r-- 1 oraper01 oinstall   1249 Dec 17 14:27 runConfig.sh.ouibak
    -rwxr-xr-x 1 oraper01 oinstall 175027 Dec 17 14:27 runInstaller
    -rwxr-xr-x 1 oraper01 oinstall     65 Dec 17 15:39 runInstaller.sh
    -rw-r--r-- 1 oraper01 oinstall     79 Dec 17 14:27 runInstaller.sh.ouibak
    
    
    TARGET$ ./runInstaller -silent -clone 
                            ORACLE_HOME="/u02/per01/app/10.2.0/db1" 
                            ORACLE_HOME_NAME="10per01" 
                            ORACLE_BASE="/u02/per01/app"
    Starting Oracle Universal Installer...
    
    No pre-requisite checks found in oraparam.ini, no system pre-requisite checks will be executed.
    Preparing to launch Oracle Universal Installer from /tmp/OraInstall2013-12-17_03-38-47PM. Please wait ...
    Oracle Universal Installer, Version 10.2.0.5.0 Production
    Copyright (C) 1999, 2010, Oracle. All rights reserved.
    
    You can find a log of this install session at:
     /u01/app/oraInventory/logs/cloneActions2013-12-17_03-38-47PM.log
    ...................................................................... 100% Done.
    Installation in progress (Tuesday, December 17, 2013 3:39:02 PM BRST)
    ...................................................................... 75% Done.
    Install successful
    Linking in progress (Tuesday, December 17, 2013 3:39:10 PM BRST)
    Link successful
    Setup in progress (Tuesday, December 17, 2013 3:39:35 PM BRST)
    Setup successful
    End of install phases.(Tuesday, December 17, 2013 3:39:37 PM BRST)
    WARNING:
    The following configuration scripts need to be executed as the "root" user.
    #!/bin/sh
    #Root script to run
    /u02/per01/app/10.2.0/db1/root.sh
    To execute the configuration scripts:
        1. Open a terminal window
        2. Log in as "root"
        3. Run the scripts
    The cloning of 10per01 was successful.
    Please check '/u01/app/oraInventory/logs/cloneActions2013-12-17_03-38-47PM.log' for more details.
    ^C
    TARGET$ exit
    logout
    TARGET# /u02/per01/app/10.2.0/db1/root.sh
    Running Oracle 10g root.sh script...
    
    The following environment variables are set as:
        ORACLE_OWNER= oraper01
        ORACLE_HOME=  /u02/per01/app/10.2.0/db1
    
    Enter the full pathname of the local bin directory: [/usr/local/bin]:
    The file "dbhome" already exists in /usr/local/bin.  Overwrite it? (y/n)
    [n]: n
    The file "oraenv" already exists in /usr/local/bin.  Overwrite it? (y/n)
    [n]: n
    The file "coraenv" already exists in /usr/local/bin.  Overwrite it? (y/n)
    [n]:
    
    Entries will be added to the /etc/oratab file as needed by
    Database Configuration Assistant when a database is created
    Finished running generic part of root.sh script.
    Now product-specific root actions will be performed.
    
     

    And that is it the database binaries are ready to start up a database instance.