Oracle Home

How to Move ORACLE HOME

Allow me to ask you a question before going further: why would you like to move ORACLE HOME to another place? You may leave your comment below this post, I am curious about it.

As for me, it’s because my client like old-fashioned file structure and don’t like Optimal Flexible Architecture (OFA) to be used, which is /u01 prefixed path.

Move ORACLE HOME

Oracle allows us to have multiple ORACLE HOME in a machine, especially when we want to have different versions of Oracle products. To move ORACLE HOME to another place, we take the following steps:

  1. Prepare to Install Oracle Product
  2. Install Oracle Software on New Home
  3. Move Network Configuration Files
  4. Move Oracle Database
  5. Deinstall Old ORACLE HOME
  6. Verify the Persistence of New Home

Prepare to Install Oracle Product

First of all, make new directories for oracle new home by root.

[root@primary ~]# mkdir -p /oracle/ora11ghome
[root@primary ~]# chown -R oracle:dba /oracle

Shutdown all Oracle services like this.

[oracle@primary ~]$ dbshut $ORACLE_HOME
Processing Database instance "ORCL": log file /u01/app/oracle/product/11.2.0/dbhome_1/shutdown.log

Change the environment variables to new locations.

[oracle@primary ~]$ vi .bash_profile
...
export ORACLE_BASE=/oracle
export ORACLE_HOME=/oracle/ora11ghome
export OLD_ORACLE_BASE=/u01/app/oracle
export OLD_ORACLE_HOME=$OLD_ORACLE_BASE/product/11.2.0/dbhome_1
...
[oracle@primary ~]$ . .bash_profile

Install Oracle Software on New Home

We should point to the new location during installation.

[oracle@primary ~]$ cd /tmp/database/
[oracle@primary database]$ ./runInstaller
...

Be sure that you select “Install database software only” at step 3 during OUI installation. Because we’ll manually move our database later.

After installation, you may check the oracle inventory for sure.

[oracle@primary database]$ cat /u01/app/oraInventory/ContentsXML/inventory.xml
<?xml version="1.0" standalone="yes" ?>
<!-- Copyright (c) 1999, 2013, Oracle and/or its affiliates.
All rights reserved. -->
<!-- Do not modify the contents of this file by hand. -->
<INVENTORY>
<VERSION_INFO>
   <SAVED_WITH>11.2.0.4.0</SAVED_WITH>
   <MINIMUM_VER>2.1.0.6.0</MINIMUM_VER>
</VERSION_INFO>
<HOME_LIST>
<HOME NAME="OraDb11g_home1" LOC="/u01/app/oracle/product/11.2.0/dbhome_1" TYPE="O" IDX="1"/>
<HOME NAME="OraDb11g_home2" LOC="/oracle/ora11" TYPE="O" IDX="2"/>
</HOME_LIST>
<COMPOSITEHOME_LIST>
</COMPOSITEHOME_LIST>
</INVENTORY>

As we can see, the new ORACLE HOME is the second HOME in this machine.

Please note that, there’s another way that also can install oracle product, which is to run OUI from this path: [oracle@primary database]$ cd $OLD_ORACLE_HOME/oui/bin
[oracle@primary bin]$ ./runInstaller
...

Both ways bring almost the same results, but I think the first approach is more flexible than this one.

Oracle Home OUI Bin runInstaller - Welcome Page
Oracle Home OUI Bin runInstaller – Welcome Page

Moreover, you can confirm the installation result in the OUI.

Oracle Home OUI Bin runInstaller - Installed Products
Oracle Home OUI Bin runInstaller – Installed Products

Move Network Configuration Files

Actually, we copied network configuration files instead of moving them.

[oracle@primary bin]$ cp -rp $OLD_ORACLE_HOME/network/admin/* $ORACLE_HOME/network/admin/
[oracle@primary bin]$ cd $ORACLE_HOME/network/admin/
[oracle@primary admin]$ ll
total 20
-rw-r--r--. 1 oracle dba       506 Aug  3 19:09 listener.ora
drwxr-xr-x. 2 oracle oinstall 4096 Feb 13  2018 samples
-rw-r--r--. 1 oracle oinstall  381 Dec 17  2012 shrept.lst
-rw-r--r--. 1 oracle dba       223 Feb 13  2018 sqlnet.ora
-rw-r-----. 1 oracle dba       326 Feb 13  2018 tnsnames.ora

Of course, we have to modify some files for the new home. Since there’s a static listener registry in listener.ora, I have to modify the file.

[oracle@primary admin]$ vi listener.ora
...
ADR_BASE_LISTENER = /oracle

SID_LIST_LISTENER=
  (SID_LIST=
    (SID_DESC=
      (ORACLE_HOME=/oracle/ora11ghome)
      (SID_NAME=ORCL))
  )

Now turn to sqlnet.ora.

[oracle@primary admin]$ vi sqlnet.ora
...
ADR_BASE = /oracle

Now we have moved ORACLE HOME to another place. Next, we should move the database (if any) to the new home.

Move Oracle Database

Since I talked about how to move Oracle database to the new home in another post, so I won’t mention it here.

Deinstall Old ORACLE HOME

If everything is fine, we can deinstall the old ORACLE HOME. Don’t forget to shutdown all database services first.

[oracle@primary ~]$ dbshut $ORACLE_HOME
...
[oracle@primary ~]$ cd $OLD_ORACLE_HOME/deinstall/
[oracle@primary deinstall]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1/deinstall
[oracle@primary deinstall]$ ./deinstall
Checking for required files and bootstrapping ...
Please wait ...
Location of logs /u01/app/oraInventory/logs/

############ ORACLE DEINSTALL & DECONFIG TOOL START ############


######################### CHECK OPERATION START #########################
## [START] Install check configuration ##


Checking for existence of the Oracle home location /u01/app/oracle/product/11.2.0/dbhome_1
Oracle Home type selected for deinstall is: Oracle Single Instance Database
Oracle Base selected for deinstall is: /u01/app/oracle
Checking for existence of central inventory location /u01/app/oraInventory
Checking for sufficient temp space availability on node(s) : 'primary.example.com'

## [END] Install check configuration ##


Network Configuration check config START

Network de-configuration trace file location: /u01/app/oraInventory/logs/netdc_check2019-01-22_06-54-48-PM.log

Specify all Single Instance listeners that are to be de-configured [LISTENER]:

Network Configuration check config END

Database Check Configuration START

Database de-configuration trace file location: /u01/app/oraInventory/logs/databasedc_check2019-01-22_06-54-56-PM.log

Use comma as separator when specifying list of values as input

Specify the list of database names that are configured in this Oracle home []:
Database Check Configuration END

Enterprise Manager Configuration Assistant START

EMCA de-configuration trace file location: /u01/app/oraInventory/logs/emcadc_check2019-01-22_06-55-04-PM.log

Enterprise Manager Configuration Assistant END
Oracle Configuration Manager check START
OCM check log file location : /u01/app/oraInventory/logs//ocm_check2484.log
Oracle Configuration Manager check END

######################### CHECK OPERATION END #########################


####################### CHECK OPERATION SUMMARY #######################
Oracle Home selected for deinstall is: /u01/app/oracle/product/11.2.0/dbhome_1
Inventory Location where the Oracle home registered is: /u01/app/oraInventory
Following Single Instance listener(s) will be de-configured: LISTENER
No Enterprise Manager configuration to be updated for any database(s)
No Enterprise Manager ASM targets to update
No Enterprise Manager listener targets to migrate
Checking the config status for CCR
Oracle Home exists with CCR directory, but CCR is not configured
CCR check is finished
Do you want to continue (y - yes, n - no)? [n]: y
A log of this session will be written to: '/u01/app/oraInventory/logs/deinstall_deconfig2019-01-22_06-54-46-PM.out'
Any error messages from this session will be written to: '/u01/app/oraInventory/logs/deinstall_deconfig2019-01-22_06-54-46-PM.err'

######################## CLEAN OPERATION START ########################

Enterprise Manager Configuration Assistant START

EMCA de-configuration trace file location: /u01/app/oraInventory/logs/emcadc_clean2019-01-22_06-55-04-PM.log

Updating Enterprise Manager ASM targets (if any)
Updating Enterprise Manager listener targets (if any)
Enterprise Manager Configuration Assistant END
Database de-configuration trace file location: /u01/app/oraInventory/logs/databasedc_clean2019-01-22_06-55-14-PM.log

Network Configuration clean config START

Network de-configuration trace file location: /u01/app/oraInventory/logs/netdc_clean2019-01-22_06-55-14-PM.log

De-configuring Single Instance listener(s): LISTENER

De-configuring listener: LISTENER
    Stopping listener: LISTENER
    Listener stopped successfully.
    Deleting listener: LISTENER
    Listener deleted successfully.
Listener de-configured successfully.

De-configuring Listener configuration file...
Listener configuration file de-configured successfully.

De-configuring Naming Methods configuration file...
Naming Methods configuration file de-configured successfully.

De-configuring Local Net Service Names configuration file...
Local Net Service Names configuration file de-configured successfully.

De-configuring backup files...
Backup files de-configured successfully.

The network configuration has been cleaned up successfully.

Network Configuration clean config END

Oracle Configuration Manager clean START
OCM clean log file location : /u01/app/oraInventory/logs//ocm_clean2484.log
Oracle Configuration Manager clean END
Setting the force flag to false
Setting the force flag to cleanup the Oracle Base
Oracle Universal Installer clean START

Detach Oracle home '/u01/app/oracle/product/11.2.0/dbhome_1' from the central inventory on the local node : Done

Delete directory '/u01/app/oracle/product/11.2.0/dbhome_1' on the local node : Done

The Oracle Base directory '/u01/app/oracle' will not be removed on local node. The directory is not empty.

Oracle Universal Installer cleanup was successful.

Oracle Universal Installer clean END


## [START] Oracle install clean ##

Clean install operation removing temporary directory '/tmp/deinstall2019-01-22_06-54-34PM' on node 'primary'

## [END] Oracle install clean ##


######################### CLEAN OPERATION END #########################


####################### CLEAN OPERATION SUMMARY #######################
Following Single Instance listener(s) were de-configured successfully: LISTENER
Cleaning the config for CCR
As CCR is not configured, so skipping the cleaning of CCR configuration
CCR clean is finished
Successfully detached Oracle home '/u01/app/oracle/product/11.2.0/dbhome_1' from the central inventory on the local node.
Successfully deleted directory '/u01/app/oracle/product/11.2.0/dbhome_1' on the local node.
Oracle Universal Installer cleanup was successful.

Oracle deinstall tool successfully cleaned up temporary directories.
#######################################################################


############# ORACLE DEINSTALL & DECONFIG TOOL END #############

Verify the Persistence of New Home

We reboot the database server to verify the result.

[root@primary ~]# init 6

After server booted, we checked all database services.

  1. Listener:
  2. [oracle@primary ~]$ lsnrctl status
    ...
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
    STATUS of the LISTENER
    ------------------------
    Alias                     LISTENER
    Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
    Start Date                22-JAN-2019 19:04:33
    Uptime                    0 days 0 hr. 0 min. 36 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Listener Parameter File   /oracle/ora11ghome/network/admin/listener.ora
    Listener Log File         /oracle/diag/tnslsnr/primary/listener/alert/log.xml
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=primary)(PORT=1521)))
    Services Summary...
    Service "ORCL" has 2 instance(s).
      Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
      Instance "ORCL", status READY, has 1 handler(s) for this service...
    Service "ORCLXDB" has 1 instance(s).
      Instance "ORCL", status READY, has 1 handler(s) for this service...
    The command completed successfully

  3. Instance:
  4. [oracle@primary ~]$ sqlplus / as sysdba
    ...
    SQL> select name, open_mode from v$database;

    NAME      OPEN_MODE
    --------- --------------------
    ORCL      READ WRITE

    SQL> show parameter spfile;

    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    spfile                               string      /oracle/ora11ghome/dbs/spfileO
                                                     RCL.ora

  5. Inventory:
  6. [oracle@primary ~]$ cat /u01/app/oraInventory/ContentsXML/inventory.xml
    <?xml version="1.0" standalone="yes" ?>
    <!-- Copyright (c) 1999, 2013, Oracle and/or its affiliates.
    All rights reserved. -->
    <!-- Do not modify the contents of this file by hand. -->
    <INVENTORY>
    <VERSION_INFO>
       <SAVED_WITH>11.2.0.4.0</SAVED_WITH>
       <MINIMUM_VER>2.1.0.6.0</MINIMUM_VER>
    </VERSION_INFO>
    <HOME_LIST>
    <HOME NAME="OraDb11g_home2" LOC="/oracle/ora11ghome" TYPE="O" IDX="2"/>
    <HOME NAME="OraDb11g_home1" LOC="/u01/app/oracle/product/11.2.0/dbhome_1" TYPE="O" IDX="1" REMOVED="T"/>
    </HOME_LIST>
    <COMPOSITEHOME_LIST>
    </COMPOSITEHOME_LIST>
    </INVENTORY>

More Considerations

Oracle mentions a way to clone an Oracle database home. The document says it will faster than a new installation. You can also take a look at it.

If you plans to abandon /u01, you should also consider to move Oracle central inventory before or after moving ORACLE HOME.

If you have deployed scripts that can auto startup database on server’s boot-time, you should also modify them in order to align with your new home. Usually, it’s /etc/init.d/dbora.

Leave a Reply

Your email address will not be published. Required fields are marked *