Home Administration Clean up after a database - using Oracle recommended 'deinstall' utility.

Clean up after a database – using Oracle recommended ‘deinstall’ utility.

Often, we are faced with an empty ORACLE_HOME and deserted configuration, diagnostic, dump and log files. This is a common situation since we regularly upgrade databases to higher versions or migrate databases to new hardware. As a result, several files are left behind. This post lists the steps to clean up after a database home is no longer used. We use Oracle’s recommended deinstall utility.

Note, Oracle does not support the removal of individual products or components. If this is the last Oracle Software on the machine, then the ORACLE_BASE will also be removed. If there are other Oracle products still installed (and in the inventory), then the ORACLE_BASE will be untouched.

Note, the steps in this post are destructive. Ensure that there are no databases operating (or shutdown) from the home you are cleaning up. Also, we often consolidate several databases running in different versions in a server. Be sure to run this utility from the correct Oracle home.

Also note, if you are executing this on a RAC cluster, you may still need the SCAN and Local Listeners which usually run from the Grid home (or another Oracle home). If the home you are de-installing has soft links to the listener.ora in Grid home, then the deinstall utility might pick it up as a candidate to remove. Do not remove the listeners if there are other databases in the cluster operating out of a different Oracle home and is still required. The steps in this post will show how to avoid removing the listeners if they are still needed.

The steps below were performed on a RAC cluster running Grid Infrastructure 18c and different versions of database homes. The database home being de-installed is 12.2.0.1.

Steps

Drop Database, if no longer needed

Backup your database if required and then drop it. My preferred way to drop a database is to use RMAN. The steps below will drop a database.

RMAN> STARTUP FORCE MOUNT;
RMAN> SQL 'ALTER SYSTEM ENABLE RESTRICTED SESSION';
RMAN> DROP DATABASE INCLUDING BACKUPS NOPROMPT;

Cleanup files and folders

After dropping the database, connect to ASM and remove any leftover directories.

Cleanup Diag and Dump directories. If you are doing this on a RAC cluster, perform the steps on all nodes.

> cd /u01/app/oracle/diag/rdbms/
> rm -rf orcl

> cd /u01/app/oracle/admin
> rm -rf orcl

Backup the inventory file. If you are doing this on a RAC cluster, perform the steps on all nodes.

> cp /u01/app/oraInventory/ContentsXML/inventory.xml /u01/app/oraInventory/ContentsXML/inventory.xml.bk
> ls -ltr /u01/app/oraInventory/ContentsXML/inventory.xml*

If you had a RAC database, remove the entries from CRS.

> srvctl remove database -d orcl

Remove symlinks (or actual) network related files from the home you are de-installing. This is important. If you have references to listener configuration files in Grid home, then the deinstall utility will also include the listeners during the cleanup.

> . oraenv
ORACLE_SID = [oracle] ? orcl
The Oracle base remains unchanged with value /u01/app/oracle
> cd $ORACLE_HOME/network/admin

> ls -ltr
lrwxrwxrwx 1 oracle oinstall    49 May 10  2019 tnsnames.ora -> /u01/app/18.0.0.0/grid/network/admin/tnsnames.ora
lrwxrwxrwx 1 oracle oinstall    47 May 10  2019 sqlnet.ora -> /u01/app/18.0.0.0/grid/network/admin/sqlnet.ora
lrwxrwxrwx 1 oracle oinstall    1470 May 10  2019 listener.ora -> /u01/app/18.0.0.0/grid/network/admin/listener.ora

> rm -rf tnsnames.ora
> rm -rf sqlnet.ora
> rm -rf listener.ora

Cleanup database entries in /etc/oratab.

> vi /etc/oratab

The deinstall utility allows you to create and use directories for temp, output, and log files. If you do not create explicit directories, the <inventory_loc>/logs and /tmp directories are used as the default location to store the output files. 

> export ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/dbhome_1
> export PATH=/u01/app/oracle/product/12.2.0.1/dbhome_1/bin:.:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin:/home/oracle/bin:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin:/u01/app/oracle/common/oracle/bin

> unset TNS_ADMIN

You can do a mock/trial run to see what the deinstall utility will do. You need to use the ‘-checkonly’ option to do it. This option will stop after the checks and will display a summary. It will not proceed to the cleanup.

Important! Do not miss the hyphen (-). If you do, you won’t get an error. The deinstall utility proceeds to deinstall and ignores the checkonly option.

> cd $ORACLE_HOME/deinstall
> ./deinstall -checkonly

After reviewing the above output, if good to proceed with cleanup, execute the deinstall utility, this time without the checkonly option.

> ./deinstall

Checking for required files and bootstrapping ...
Please wait ...
Location of logs /u01/app/oraInventory/logs/

############ ORACLE DECONFIG TOOL START ############


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


Checking for existence of the Oracle home location /u01/app/oracle/product/12.2.0.1/dbhome_1
Oracle Home type selected for deinstall is: Oracle Real Application Cluster Database
Oracle Base selected for deinstall is: /u01/app/oracle
Checking for existence of central inventory location /u01/app/oraInventory
Checking for existence of the Oracle Grid Infrastructure home /u01/app/18.0.0.0/grid
The following nodes are part of this cluster: rac1db01,rac1db02,rac1db04,rac1db03
Active Remote Nodes are rac1db02,rac1db03,rac1db04
Checking for sufficient temp space availability on node(s) : 'rac1db01,rac1db02,rac1db03,rac1db04'

## [END] Install check configuration ##


Network Configuration check config START

Network de-configuration trace file location: /u01/app/oraInventory/logs/netdc_check2020-01-30_09-26-22-PM.log

Network Configuration check config END

Database Check Configuration START

Database de-configuration trace file location: /u01/app/oraInventory/logs/databasedc_check2020-01-30_09-26-35-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
Oracle Configuration Manager check START
OCM check log file location : /u01/app/oraInventory/logs//ocm_check3605.log
Oracle Configuration Manager check END

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


####################### DECONFIG CHECK OPERATION SUMMARY #######################
Oracle Grid Infrastructure Home is: /u01/app/18.0.0.0/grid
The following nodes are part of this cluster: rac1db01,rac1db02,rac1db04,rac1db03
Active Remote Nodes are rac1db02,rac1db03,rac1db04
The cluster node(s) on which the Oracle home deinstallation will be performed are:rac1db01,rac1db02,rac1db03,rac1db04
Oracle Home selected for deinstall is: /u01/app/oracle/product/12.2.0.1/dbhome_1
Inventory Location where the Oracle home registered is: /u01/app/oraInventory
Checking the config status for CCR
rac1db01 : Oracle Home exists with CCR directory, but CCR is not configured
rac1db02 : Oracle Home exists with CCR directory, but CCR is not configured
rac1db03 : Oracle Home exists with CCR directory, but CCR is not configured
rac1db04 : 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_deconfig2020-01-30_09-26-06-PM.out'
Any error messages from this session will be written to: '/u01/app/oraInventory/logs/deinstall_deconfig2020-01-30_09-26-06-PM.err'

######################## DECONFIG CLEAN OPERATION START ########################
Database de-configuration trace file location: /u01/app/oraInventory/logs/databasedc_clean2020-01-30_09-27-01-PM.log

Network Configuration clean config START

Network de-configuration trace file location: /u01/app/oraInventory/logs/netdc_clean2020-01-30_09-27-01-PM.log

De-configuring Listener configuration file on all nodes...
Listener configuration file de-configured successfully.

De-configuring Naming Methods configuration file on all nodes...
Naming Methods configuration file de-configured successfully.

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

De-configuring Directory Usage configuration file on all nodes...
Directory Usage configuration file de-configured successfully.

De-configuring backup files on all nodes...
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_clean3605.log
Oracle Configuration Manager clean END

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


####################### DECONFIG CLEAN OPERATION SUMMARY #######################
Cleaning the config for CCR
As CCR is not configured, so skipping the cleaning of CCR configuration
CCR clean is finished
#######################################################################


############# ORACLE DECONFIG TOOL END #############

Using properties file /tmp/deinstall2020-01-30_09-26-01PM/response/deinstall_2020-01-30_09-26-06-PM.rsp
Location of logs /u01/app/oraInventory/logs/

############ ORACLE DEINSTALL TOOL START ############





####################### DEINSTALL CHECK OPERATION SUMMARY #######################
A log of this session will be written to: '/u01/app/oraInventory/logs/deinstall_deconfig2020-01-30_09-26-06-PM.out'
Any error messages from this session will be written to: '/u01/app/oraInventory/logs/deinstall_deconfig2020-01-30_09-26-06-PM.err'

######################## DEINSTALL CLEAN OPERATION START ########################
## [START] Preparing for Deinstall ##
Setting LOCAL_NODE to rac1db01
Setting REMOTE_NODES to rac1db02,rac1db03,rac1db04
Setting CLUSTER_NODES to rac1db01,rac1db02,rac1db03,rac1db04
Setting CRS_HOME to false
Setting oracle.installer.invPtrLoc to /tmp/deinstall2020-01-30_09-26-01PM/oraInst.loc
Setting oracle.installer.local to false

## [END] Preparing for Deinstall ##

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/12.2.0.1/dbhome_1' from the central inventory on the local node : Done

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

The Oracle Base directory '/u01/app/oracle' will not be removed on local node. The directory is in use by Oracle Home '/u01/app/18.0.0.0/grid'.

Detach Oracle home '/u01/app/oracle/product/12.2.0.1/dbhome_1' from the central inventory on the remote nodes 'rac1db02,rac1db04,rac1db03' : Done

Delete directory '/u01/app/oracle/product/12.2.0.1/dbhome_1' on the remote nodes 'rac1db02,rac1db03,rac1db04' : Done

The Oracle Base directory '/u01/app/oracle' will not be removed on node 'rac1db02'. The directory is in use by Oracle Home '/u01/app/18.0.0.0/grid'.

The Oracle Base directory '/u01/app/oracle' will not be removed on node 'rac1db04'. The directory is in use by Oracle Home '/u01/app/18.0.0.0/grid'.

The Oracle Base directory '/u01/app/oracle' will not be removed on node 'rac1db03'. The directory is in use by Oracle Home '/u01/app/18.0.0.0/grid'.

Oracle Universal Installer cleanup was successful.

Oracle Universal Installer clean END


## [START] Oracle install clean ##

Clean install operation removing temporary directory '/tmp/deinstall2020-01-30_09-26-01PM' on node 'rac1db02,rac1db03,rac1db04'

## [END] Oracle install clean ##


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


####################### DEINSTALL CLEAN OPERATION SUMMARY #######################
Successfully detached Oracle home '/u01/app/oracle/product/12.2.0.1/dbhome_1' from the central inventory on the local node.
Successfully deleted directory '/u01/app/oracle/product/12.2.0.1/dbhome_1' on the local node.
Successfully detached Oracle home '/u01/app/oracle/product/12.2.0.1/dbhome_1' from the central inventory on the remote nodes 'rac1db02,rac1db04,rac1db03'.
Successfully deleted directory '/u01/app/oracle/product/12.2.0.1/dbhome_1' on the remote nodes 'rac1db02,rac1db03,rac1db04'.
Oracle Universal Installer cleanup was successful.

Review the permissions and contents of '/u01/app/oracle' on nodes(s) 'rac1db01,rac1db02,rac1db03,rac1db04'.
If there are no Oracle home(s) associated with '/u01/app/oracle', manually delete '/u01/app/oracle' and its contents.
Oracle deinstall tool successfully cleaned up temporary directories.
#######################################################################


############# ORACLE DEINSTALL TOOL END #############

At this point, the binaries are removed and detached from the inventory. 

I have tested the deinstall utility on 12c and 11g. It works fine on both versions. If you are interested in the output of an 11g deinstall, see below. Else scroll down and leave your comment. I’d appreciate it.

Output from an 11g 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.3/dbhome_1
Oracle Home type selected for deinstall is: Oracle Real Application Cluster Database
Oracle Base selected for deinstall is: /u01/app/oracle
Checking for existence of central inventory location /u01/app/oraInventory
Checking for existence of the Oracle Grid Infrastructure home /u01/app/12.2.0.1/grid
The following nodes are part of this cluster: rac3db01,rac3db02,rac3db03,rac3db04,rac3db05,rac3db06
Checking for sufficient temp space availability on node(s) : 'rac3db01,rac3db02,rac3db03,rac3db04,rac3db05,rac3db06'

## [END] Install check configuration ##


Network Configuration check config START

Network de-configuration trace file location: /u01/app/oraInventory/logs/netdc_check2020-02-19_06-50-30-PM.log

Network Configuration check config END

Database Check Configuration START

Database de-configuration trace file location: /u01/app/oraInventory/logs/databasedc_check2020-02-19_06-50-33-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_check2020-02-19_06-50-48-PM.log

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

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


####################### CHECK OPERATION SUMMARY #######################
Oracle Grid Infrastructure Home is: /u01/app/12.2.0.1/grid
The cluster node(s) on which the Oracle home deinstallation will be performed are:rac3db01,rac3db02,rac3db03,rac3db04,rac3db05,rac3db06
Oracle Home selected for deinstall is: /u01/app/oracle/product/11.2.0.3/dbhome_1
Inventory Location where the Oracle home registered is: /u01/app/oraInventory
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
rac3db01 : Oracle Home exists and CCR is configured
rac3db02 : Oracle Home exists and CCR is configured
rac3db03 : Oracle Home exists and CCR is configured
rac3db04 : Oracle Home exists and CCR is configured
rac3db05 : Oracle Home exists and CCR is configured
rac3db06 : Oracle Home exists and CCR is 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_deconfig2020-02-19_06-50-21-PM.out'
Any error messages from this session will be written to: '/u01/app/oraInventory/logs/deinstall_deconfig2020-02-19_06-50-21-PM.err'

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

Enterprise Manager Configuration Assistant START

EMCA de-configuration trace file location: /u01/app/oraInventory/logs/emcadc_clean2020-02-19_06-50-48-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_clean2020-02-19_06-51-28-PM.log

Network Configuration clean config START

Network de-configuration trace file location: /u01/app/oraInventory/logs/netdc_clean2020-02-19_06-51-28-PM.log

De-configuring Listener configuration file on all nodes...
Listener configuration file de-configured successfully.

De-configuring Naming Methods configuration file on all nodes...
Naming Methods configuration file de-configured successfully.

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

De-configuring Directory Usage configuration file on all nodes...
Directory Usage configuration file de-configured successfully.

De-configuring backup files on all nodes...
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_clean3683.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.3/dbhome_1' from the central inventory on the local node : Done

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

The Oracle Base directory '/u01/app/oracle' will not be removed on local node. The directory is in use by Oracle Home '/u01/app/12.1.0.2/grid'.

Detach Oracle home '/u01/app/oracle/product/11.2.0.3/dbhome_1' from the central inventory on the remote nodes 'rac3db06,rac3db02,rac3db04,rac3db05,rac3db03' : Done

Delete directory '/u01/app/oracle/product/11.2.0.3/dbhome_1' on the remote nodes 'rac3db02,rac3db03,rac3db04,rac3db05,rac3db06' : Done

The Oracle Base directory '/u01/app/oracle' will not be removed on node 'rac3db06'. The directory is in use by Oracle Home '/u01/app/12.1.0.2/grid'.

The Oracle Base directory '/u01/app/oracle' will not be removed on node 'rac3db02'. The directory is in use by Oracle Home '/u01/app/12.1.0.2/grid'.

The Oracle Base directory '/u01/app/oracle' will not be removed on node 'rac3db04'. The directory is in use by Oracle Home '/u01/app/12.1.0.2/grid'.

The Oracle Base directory '/u01/app/oracle' will not be removed on node 'rac3db05'. The directory is in use by Oracle Home '/u01/app/12.1.0.2/grid'.

The Oracle Base directory '/u01/app/oracle' will not be removed on node 'rac3db03'. The directory is in use by Oracle Home '/u01/app/12.1.0.2/grid'.

Oracle Universal Installer cleanup was successful.

Oracle Universal Installer clean END


## [START] Oracle install clean ##

Clean install operation removing temporary directory '/tmp/deinstall2020-02-19_06-50-16PM' on node 'rac3db01'
Clean install operation removing temporary directory '/tmp/deinstall2020-02-19_06-50-16PM' on node 'rac3db02,rac3db03,rac3db04,rac3db05,rac3db06'

## [END] Oracle install clean ##


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


####################### CLEAN OPERATION SUMMARY #######################
Cleaning the config for CCR
Cleaning the CCR configuration by executing its binaries
CCR clean is finished
Successfully detached Oracle home '/u01/app/oracle/product/11.2.0.3/dbhome_1' from the central inventory on the local node.
Successfully deleted directory '/u01/app/oracle/product/11.2.0.3/dbhome_1' on the local node.
Successfully detached Oracle home '/u01/app/oracle/product/11.2.0.3/dbhome_1' from the central inventory on the remote nodes 'rac3db06,rac3db02,rac3db04,rac3db05,rac3db03'.
Successfully deleted directory '/u01/app/oracle/product/11.2.0.3/dbhome_1' on the remote nodes 'rac3db02,rac3db03,rac3db04,rac3db05,rac3db06'.
Oracle Universal Installer cleanup was successful.

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


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

Was this post helpful? Is there anything that you would do differently. I would love to hear your thoughts.

References: 

Removing Oracle Database Software – 12cR2
Removing Oracle Database Software – 11gR2

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest posts

How to rename a PDB in 19c

Let's look at how to rename a PDB in 19c. The steps are the same as 12c....

How to change the ethernet switch password on Exadata

Let's look at how to log in and change the ethernet switch (adm) password on an Exadata...

Install Oracle GoldenGate Plug-in on Oracle Enterprise Manager Cloud Control 13c

In this post, we will install and deploy Oracle GoldenGate Plug-in 13.4.1.0 on Oracle Enterprise Manager Cloud...

Fixed – EXPDP – OS/ Wallet Authentication does not work, prompts for password

I recently encountered a strange issue on a newly created multitenant database on 19.6 version. Our EXPDP...

You might also likeRELATED
Recommended to you