Andy Kerber (@dbakerber), Senior Consultant
One common Oracle DBA problem is migrating to new hardware. Typically, the Oracle database will be moved to new hardware, either on the same, or an upgraded version, of the same operating system. When moving a database, a DBA should take care to minimize the potential issues in this move, and a standard task is to make sure that the Oracle database is the exact same version on both the old and new server.
Often there is an Oracle upgrade involved in the migration process, but even so there is normally a requirement to have a copy of the old Oracle home on the new server. The safest method to ensure the Oracle database home that is created on the new server is identical to the old one is to simply clone the existing Oracle home.
The only drawback to this method is that a brief downtime is required to clone the existing Oracle home. If a downtime window is not available, then you will need to choose another method.
Below are the steps for cloning an existing Oracle home to a new server.
- Make sure the Oracle home you are using has all necessary patches installed.
- Stop all processes in the Oracle home to be cloned. Typically, this will be the Oracle database process and the listener. Once they are stopped, use the fuser command to identify any remaining processes, fuser –v –c /u01/app/oracle/product/12.1.0.2/dbhome_1. The output will be similar to below:
USER PID ACCESS COMMAND /u01/app/oracle/product/12.1.0/dbhome_1: root kernel mount / oracle 3381 .r.e. bash oracle 3731 Fr.e. tnslsnr
If there are any processes listed, which correspond to the Oracle database (e.g. tnslsnr) kill them.
- Create a zip or tar file containing the Oracle home, but not the Oracle base. Exclude any files you do not want to carry over using the –x option, for example:
zip -r dbhome_1.zip /u01/app/oracle/product/12.1.0/dbhome_1 -x "/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora" "/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/tnsnames.ora" “/u01/app/oracle/product/12.1.0/dbhome_1/oradata/*”
- At this point, you will have a file named dbhome_1.zip (in this case) that contains a good Oracle home directory.
- Copy this file to your new server, and make sure all the required Oracle prerequisites are installed. If you are installing on Oracle Enterprise Linux, you can ensure this by installing the Oracle preinstall package for your current Oracle version (e.g.. oracle-rdbms-server-12cR1-preinstall). If using Red Hat Enterprise Linux or other versions, review this Oracle Metalink document for the required packages: note 1587357.1.
- Create the top-level directory and change the ownership to oracle, e.g. mkdir –p /u01, chown oracle:oinstall /u01.
- Unzip the file using the –d option to create the entire directory tree: unzip –d / dbhome_1.zip. This will recreate a directory structure identical to the old structure on your new server.
- In order to reduce the chance of typos and to save typing, set the ORACLE_HOME environment variable to your new Oracle home, e.g. export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
- Move to the /u01/app/oracle/product/12.1.0/dbhome_1/clone/bin directory and run the clone command to install and register the new Oracle home. The syntax of the command is:
$ORACLE_HOME/perl/bin/perl $ORACLE_HOME/clone/bin/clone.pl ORACLE_BASE="target_oracle_base" ORACLE_HOME="target_oracle_home" OSDBA_GROUP=OSDBA_privileged_group OSOPER_GROUP=OSOPER_privileged_group –defaultHomeName
- Below is the command used and the output:
$ORACLE_HOME/perl/bin/perl $ORACLE_HOME/clone/bin/clone.pl ORACLE_BASE="/u01/app/oracle/" ORACLE_HOME="/u01/app/oracle/product/12.1.0/dbhome_1" OSDBA_GROUP=dba OSOPER_GROUP=dba –defaultHomeName ./runInstaller -clone -waitForCompletion "ORACLE_BASE=/u01/app/oracle/" "ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1" -silent -paramFile /u01/app/orac le/product/12.1.0/dbhome_1/clone/clone_oraparam.ini Starting Oracle Universal Installer...
Checking Temp space: must be greater than 500 MB. Actual 50368 MB Passed Checking swap space: must be greater than 500 MB. Actual 16379 MB Passed Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-05-13_08-48-15PM. Please wait ...You can find the log of this install session at: /u01/app/oraInventory/logs/cloneActions2018-05-13_08-48-15PM.log .................................................. 5% Done. .................................................. 10% Done. .................................................. 15% Done. .................................................. 20% Done. .................................................. 25% Done. .................................................. 30% Done. .................................................. 35% Done. .................................................. 40% Done. .................................................. 45% Done. .................................................. 50% Done. .................................................. 55% Done. .................................................. 60% Done. .................................................. 65% Done. .................................................. 70% Done. .................................................. 75% Done. .................................................. 80% Done. .................................................. 85% Done. .......... Copy files in progress. Copy files successful. Link binaries in progress. Link binaries successful. Setup files in progress. Setup files successful. Setup Inventory in progress. Setup Inventory successful. Finish Setup successful. The cloning of OraHome1 was successful. Please check '/u01/app/oraInventory/logs/cloneActions2018-05-13_08-48-15PM.log' for more details. Setup Oracle Base in progress. Setup Oracle Base successful. .................................................. 95% Done. As a root user, execute the following script(s):
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/12.1.0/dbhome_1/root.sh
- At this point, you have successfully cloned your Oracle home. The next step is to copy your old database over to the new home on your brand new server.
In this article we have given an example of how to clone an existing Oracle home to a new server. This is a useful method for ensuring that you have the same software versions on both your old and new servers.