What is cloning?
Cloning is a process of copying an existing installation to a different server or location. Cloning is similar to an Oracle installation except Oracle universal installation performs the actions in a special mode called “clone mode”.
Starting from 10g onwards, Oracle supports cloning and users can easily clone existing Oracle installations. The source and destination servers should have same configuration and packages installed in order Oracle cloning to work. The cloning process works by copying all files from the source Oracle home to the destination Oracle home, and files which are not part of the source instance will not be copied to the destination location.
When it comes to a server upgrade or migration, database administrators will have to question whether to clone or install the Oracle binaries. In the next steps, I’ll explain why it’s useful and the processes involved.
When is cloning useful?
- If you need to create a new installation with many patches, then cloning enables you to create a new installation with all patches applied to it in one step and eliminate manual installation.
- To create an installation that is the same as Production for Development/Testing purpose
- If you need to create Oracle home and deploy it to many hosts
- If you need to quickly deploy an instance and the applications
Note that the clone installation behaves the same as source installation. You can patch Oracle home using OPatch and you can remove using the Oracle universal installer. But cloning is not possible across the platforms.
Methods available for Cloning
You can use one of the below methods to clone the Oracle installation:
- Clone using “perl clone.pl”In this method you need to install DB Console so that the required Perl files will be installed in $ORACLE_HOME/clone/bin.
- Clone using “runInstaller”In this method you need to install DB Console
- Clone using “runInstaller in silent” modeIn this method you will be using same “runInstaller” in non-interactive mode
How is Cloning done?
Cloning is a two-step process, in the first step you will copy Oracle installation from source to destination and in second step you will run Oracle Universal Installer to clone the installation on the destination.
Step 1: Copy source Oracle Installation
Before you make a copy of the existing installation, the databases, listeners and agents, etc running on the server should be shut down on the source installation.
The source Oracle home will have configuration/trace/log files related to the environment such as udump, bdump, alert.log , init.ora, listener.ora, tnsnames.ora, etc. When you clone the Oracle home, the destination will have all those files. If your destination will have different database/instances then your need to exclude those files during copy.
If your requirement is server migration and then no need to exclude those files.
Below are the lists of few files that may need to exclude during the cloning process, in case your destination will be different.
- Database related files (Data/tmp files, log files, Control files…etc)
- SQL*Net Files $
$ORACLE_HOME/listener.ora
$ORACLE_HOME/tnsnames.ora
$ORACLE_HOME/sqlnet.ora
- Database related directories
$ORACLE_HOME/dbs ( init.ora,spfile.ora,orapwd)
$ORACLE_HOME/admin (trace, alert, core files…etc)
$ORACLE_BASE/diag (trace, alert, core, incident files…etc)
$ORACLE_HOME/oc4j/j2ee/OC4J_DBConsole__ (Enterprise manager/db console)
$ORACLE_HOME/hs/admin/ (heterogeneous files)
Note that for Database 11g the permissions are more restrictive for the files $ORACLE_HOME/bin/nmo, $ORACLE_HOME/bin/nmb and $ORACLE_HOME/bin/nmhs. When you attempt to tar or copy you will receive the “permission denied” error. For 11g and higher, add these files to the exclusion list, they’ll be created by root.sh script later in the cloning process.
If any other products are installed/configured but not required at destination, then you need to exclude those files as well.
Make a copy using “tar”:
You can create an exclude list as below
$ cat exclude_list.txt
./network/admin/listener.ora
./network/admin/sqlnet.ora
./network/admin/tnsnames.ora
./oc4j/j2ee/OC4J_DBConsole_oelinux.localdomain_ora11gr2
./oc4j/j2ee/OC4J_DBConsole
……
……
…etc
Create a tar file by excluding files or directories which are not required using below command
$ cd $ORACLE_HOME
$ tar -zcvf ~/Oracle_Home11g_clone.tar.gz . -X ~/exclude_list.txt > ~/ Oracle_Home11g_clone.log
On the destination server create directory structure and set the environment variables such as ORACLE_HOME, ORACLE_BASE, etc.
$ mkdir /home/oracle/product/11.2.0.4/dbhome_1
$ chown –R oracle:dba/ oracle
Copy the tar file to destination server and unpack.
$ cd $ORACLE_HOME
$ tar -xvf Oracle_Home11g_clone.tar.gz
Make a copy using “cp –RP”
If the source and destination of Oracle installation is on the same server then “cp –Rp” should be used.
$ cp -Rp $ORACLE_HOME /$ORACLE_HOME_clone
Step 2: Clone Oracle Installation
On the Destination make sure that ORACLE_HOME and ORACLE_BASE environment variables are set. The /etc/orainst.loc (for AIX,Linux), /var/opt/oracle/oraInst.loc (for Solaris,HP-UX) file should exists on the destination server. These files will not exist if Oracle never installed on the destination server, in that case you’ll need to create these files manually.
Here is the sample file
$ cat /etc/oraInst.loc
inventory_loc=/home/oracle/oraInventory
inst_group=dba
Where INVENTORY_LOCATION is the path of the oraInventory location.
If orainst.loc file exists on a different location then you can create a soft link or edit the $ORACLE_HOME/clone/config/cs.properties file and add “–invPtrLoc /oraInst.loc” parameter to “clone_command_line”.
If you have copied oracle Inventory, then you will receive a message that the inventory already exists when you run “clone.pl” or “./runInstaller” to clone the Oracle installation. So before you run cloning commands makes sure to detach the Oracle home.
See below See the below example to detach the oracle inventory:
$ cd /home/oracle/product/11.2.0/dbhome_1/oui/bin
$./runInstaller -detachHome ORACLE_HOME=/home/oracle/product/10.2.0/db_1
Starting Oracle Universal Installer...
No pre-requisite checks found in oraparam.ini, no system pre-requisite checks will be executed.
The inventory pointer is located at /etc/oraInst.loc
The inventory is located at /home/oracle/oraInventory
‘DetachHome’ was successful.
The inventory pointer is located at /etc/oraInst.loc
The inventory is located at /home/oracle/oraInventory
‘DetachHome’ was successful.
Note: – If it is the first Oracle home on the destination server then cloning will create the Inventory with the new Oracle home. If it is NOT the first Oracle home then it will update the existing inventory with New Oracle home.
1. Clone using “perl clone.pl”
$ cd $ORACLE_HOME/clone/bin
$ perl clone.pl ORACLE_HOME="" ORACLE_HOME_NAME=""
Where
ORACLE_HOME: specifies the new Oracle home directory location
ORACLE_HOME_NAME: specifies a unique name for the Oracle Home for the server
ORACLE_HOME: specifies the new Oracle home directory location
ORACLE_HOME_NAME: specifies a unique name for the Oracle Home for the server
See the below example to clone the installation using “perl clone.pl”.
2. Clone using “runInstaller”
$ORACLE_HOME/oui/bin/runInstaller -clone ORACLE_HOME=""
ORACLE_HOME_NAME=""
Where
-clone: specifies that the home is a clone of another location
ORACLE_BASE: specifies the base directory location for Oracle products
ORACLE_HOME: specifies the new Oracle home directory location
ORACLE_HOME_NAME: specifies a unique name for the Oracle Home for the server
See the below example to clone the installation using “runInstaller”.
3. Clone using “runInstaller in silent” mode
See the below example to clone the installation using “runInstaller in silent” mode.
To complete the clone you should log in as “root” and run $ORACLE_HOME/root.sh.
# /home/oracle/product/11.2.0.4/dbhome_1/root.sh
Performing root user operation for Oracle 11g
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /home/oracle/product/11.2.0.4/dbhome_1
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...
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 script.
Now product-specific root actions will be performed.
Finished product-specific root actions.
Finished product-specific root actions.
On UNIX & Linux platforms run “changePerm.sh” for versions 10g and older.
#/home/oracle/product/10.2.0/db_1/install/changePerm.sh -o /home/oracle/product/10.2.0/db_1
------------------------------------------------------------------------------
Disclaimer: The purpose of this script is to relax permissions on some of the
files in the database Oracle Home so that all clients can access them.
Please note that Oracle Corporation recommends using the most restrictive file
permissions as possible for your given implementation. Running this script
should be done only after considering all security ramifications.
-------------------------------------------------------------------------------
Do you wish to continue (y/n) [n]: y
Spooling the error log /tmp/changePerm_err.log...
Finished running the script successfully
References:-
- How To Clone An Existing RDBMS Installation Using OUI (Doc ID 300062.1)
- 11g Install : Understanding Oracle Base, Oracle Home and Oracle Central/Global Inventory locations (Doc ID 454442.1)
- FAQs on RDBMS Oracle Home Cloning Using OUI (Doc ID 565009.1)
- Cloning An Existing Oracle10g Release 2 (10.2.0.x) RDBMS Installation Using OUI (Doc ID 559304.1)
- Cloning An Existing Oracle11g Release 2 (11.2.0.x) RDBMS Installation Using OUI (Doc ID 1221705.1)
Conclusion:
This article helps Oracle community to understand when cloning is useful, available methods and how to clone an Oracle installation.
No comments:
Post a Comment