Manually Cloning an Existing Oracle Database Installation on Linux
This article describes the steps necessary to manually clone an existing Oracle database installation to a new Linux server. It was written in response to a specific request for a manual process for cloning a 9i home on a test system. Before starting this process it's worth reading the following notes:
- If I were doing a production installation I would not use this method. I like the security of knowing the installation went cleanly.
- This method assumes there are no cluster-related services, so it does not cover installations using ASM or RAC.
- It is assumed the source and destination server have exactly the same setup. That is, all the Oracle prerequisites have been performed on the destination server. In this example, the only difference between the two servers is the hostname and IP address.
- There are several Oracle Support notes on cloning installations using the Oracle Universal Installer (OUI) and Grid Control (GC), so you should consider those before considering this method. See Master Note For Cloning Oracle Database Server ORACLE_HOME's Using the Oracle Universal Installer (OUI) (Doc ID 1154613.1).
With those points in mind, here are the list of steps necessary to clone an existing database installation to a new server.
- Stop Oracle
- Create TAR File
- Transfer TAR File
- Extract TAR File
- Check File Ownership
- Root Configuration Scripts
- Modify Config Files
- Start Oracle
- Additional Configuration
- Changing ORACLE_HOME Path
Turn off all Oracle-related services, including the Enterprise Manager Grid Control, database and listener.
$ # EM $ emctl stop dbconsole $ # database and listener (>=10g) $ dbshut $ORACLE_HOME $ # listener (<10g) $ lsnrctl stop
Create TAR File
TAR and optionally compress the mount point containing the Oracle software. In this case, all Oracle software and datafiles are beneath the "/u01" directory. Perform the following command as the "root" user.
# tar -cvf /tmp/u01.tar /u01 # gzip /tmp/u01.tar
Once this is complete you can restart Oracle on the source server.
Transfer TAR File
Copy the file from the source to the destination server. You can do this transfer using which ever method you like, but here I will use SCP command from the source server.
# scp /tmp/u01.tar.gz email@example.com:/tmp/u01.tar.gz
Extract TAR File
Decompress and extract the contents of the TAR file on the destination server. Perform the following commands as the "root" user on the destination server.
# gunzip /tmp/u01.tar.gz # cd / # tar -xvf /tmp/u01.tar
Check File Ownership
Check the ownership of the "/u01" directory and it's contents. If it doesn't match the ownership of the source server, alter it to match.
# chown -R oracle:oinstall /u01
Root Configuration Scripts
Run the root configutation scripts, generated as part of the original installation, on the destination server as the "root" user.
Modify Config Files
If you have not prepared the ".bash_profile" as part of the destination server setup, copy the file from the source to the destination server.
# scp /home/oracle/.bash_profile firstname.lastname@example.org:/home/oracle/.bash_profile
Edit the ".bash_profile" file on the destination server, giving it the correct value for the ORACLE_HOSTNAME environment variable.
Amend any hostname or IP references in the "listener.ora" and "tnsnames.ora" files in the "$ORACLE_HOME/network/admin" directory.
Edit the "/etc/oratab" making sure all instances are referenced correctly. In my case I need to add the following entry.
Start the listener and database.
$ # listener (<10g) $ lsnrctl start $ # database and listener (>=10g) $ dbstart $ORACLE_HOME
The database should now be functioning normally on the destination server.
If you are using Enterprise Manager Database Control (>= 10g), you will need to reconfigure it using the method described here.
If you require your database to restart automatically after reboot, configure it using the method specified here.
For more information see:
- Master Note For Cloning Oracle Database Server ORACLE_HOME's Using the Oracle Universal Installer (OUI) (Doc ID 1154613.1)
- Basic Enterprise Manager Troubleshooting
- Automating Database Startup and Shutdown on Linux
Changing ORACLE_HOME Path
The instructions above assume the path of the
ORACLE_HOME matches between the two servers. If the new home has a different path, a straight rename won't work. The simplest way to deal with the renamed path is to use the
clone.pl script. The following example does a rename of an existing home.
After turning off all processes, rename the ORACLE_HOME.
cd $ORACLE_BASE/product/19.0.0/ mv dbhome_1 dbhome_2
ORACLE_HOME parameters to the new values.
export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/19.0.0/dbhome_2
Run the "clone.pl" script, passing in the
ORACLE_HOME and OS groups.
$ORACLE_HOME/perl/bin/perl \ $ORACLE_HOME/clone/bin/clone.pl \ ORACLE_BASE="$ORACLE_BASE" \ ORACLE_HOME="$ORACLE_HOME" \ OSDBA_GROUP=dba \ OSOPER_GROUP=dba \ -defaultHomeName
Run the "root.sh" script in the
Edit the "/etc/oratab" file and any custom environment files to reflect the new path. You can then restart the Oracle services as normal.
In 19c the "clone.pl" script is deprecated. Using it will produce the following warning.
[INFO] [INS-32183] Use of clone.pl is deprecated in this release. Clone operation is equivalent to performing a Software Only installation from the image. You must use /u01/app/oracle/product/19.0.0/dbhome_1/runInstaller script available to perform the Software Only install. For more details on image based installation, refer to help documentation.
Thanks to Brian Fitzgerald for pointing this out.
Hope this helps. Regards Tim...