Shortcut to Fixing a Corrupted Oracle Inventory

By | In Oracle | February 23rd, 2016

ShortcutThe Oracle Central Inventory is used to document and track all Oracle software products on a given host (machine). Each piece of Oracle software has its own Central Inventory pointer file.

The Central Inventory is used to provide details of all patches applied to a given installation. It also allows users to check for any conflicts between items to be installed. The Oracle Inventory is an essential tool for supporting your Oracle environment.

I’m working with a customer to streamline, stabilize, and secure their entire infrastructure. The latest Patch Set Updates (PSU) were delivered and I started detailing the process to get that patch set into their development environment.

Because the Inventory is used to detail software installation and current patch levels, I needed to check it to be able to install the patches.  I was unable to run theopatch lsinventorycommand. The information returned suggested the Inventory was corrupted. Specifically, the message returned was:

Inventory load failed… OPatch cannot load inventory for the given Oracle Home.

Possible causes are:

Oracle Home dir. path does not exist in Central Inventory

Oracle Home is a symbolic link

Oracle Home inventory is corrupted

LsInventorySession failed: OracleHomeInventory gets null oracleHomeInfo

I dug through Support Documents, tried my hand at fixing the inventory, and even attempted to manually edit the inventory.  In this instance it was easier and quicker to rebuild the corrupted inventory.

In order to do so, I needed to run the following code:

[devenv01]/home/oracle > hostname

devenv01

Checking oratab I see that three different Oracle Home versions are in use, as follows:

cat /etc/oratab

devcog:/u01/app/oracle/product/12.1.0.2/db_1:Y

devbrg:/u01/app/oracle/product/10.2.0.4/db_1:Y

devdocs:/u01/app/oracle/product/11.2.0.4/db_1:Y

devsieb:/u01/app/oracle/product/12.1.0.2/db_1:Y

devstor:/u01/app/oracle/product/11.2.0.4/db_1:Y

devsbl:/u01/app/oracle/product/12.1.0.2/db_1:Y

devhr:/u01/app/oracle/product/12.1.0.2/db_1:Y

Next, running the Inventory list allows me to discover the precise Inventory location.

Oracle Home       : /u01/app/oracle/product/12.1.0.2/db_1

Central Inventory : /u01/app/oracle/oraInventory

from           : /u01/app/oracle/product/12.1.0.2/db_1/oraInst.loc

OPatch version    : 12.1.0.1.7

OUI version       : 12.1.0.2.0

Log file location : /u01/app/oracle/product/12.1.0.2/db_1/cfgtoollogs/opatch/opatch2016-01-20_15-09-10PM_1.log

I now set $ORACLE_HOME to 12.1. This ensures I am now using software from the latest installation. I need to go to that Inventory location and backup the Inventory File:

pwd:

/u01/app/oracle/oraInventory/ContentsXML

[devenv01]/u01/app/oracle/oraInventory/ContentsXML> cp inventory.xml inventory.xml.bkup.01202016

Now, delete or remove the original Inventory file.

[devenv01]/u01/app/oracle/oraInventory/ContentsXML> > inventory.xml

The simplest fix in this particular case was to build the Inventory via loading each Oracle Home. This approach should work for release 10gR2 or higher. To execute:

ORACLE_HOME=/u01/app/oracle/product/10.2.0.4/db_1

ORACLE_HOME_NAME=OraDb10g_home1

ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1

ORACLE_HOME_NAME=OraDb11g_home1

ORACLE_HOME=/u01/app/oracle/product/12.2.0.4/db_1

ORACLE_HOME_NAME=OraDb12c_home1

Then, once this task is complete, you need to move to the Installer directory of Oracle Home:

cd /u01/app/oracle/product/12.1.0.2/db_1/oui/bin

[devenv01]/u01/app/oracle/product/12.1.0.2/db_1/oui/bin> ls

addLangs.sh*           filesList.bat*         lsnodes*               runInstaller*

attachHome.sh*         filesList.properties*  resource/              runInstaller.sh*

detachHome.sh*         filesList.sh*          runConfig.sh*          runSSHSetup.sh*

Populate the inventory with the Attach Home command.  Repeat this process for each and every installation.

./runInstaller -silent -ignoreSysPrereqs -attachHome ORACLE_HOME=”/u01/app/oracle/product/10.2.0.4/db_1″ ORACLE_HOME_NAME=”OraDb10g_home1″

./runInstaller -silent -ignoreSysPrereqs -attachHome ORACLE_HOME=”/u01/app/oracle/product/11.2.0.4/db_1″ ORACLE_HOME_NAME=”OraDb11g_home1″

./runInstaller -silent -ignoreSysPrereqs -attachHome ORACLE_HOME=”/u01/app/oracle/product/12.1.0.2/db_1″ ORACLE_HOME_NAME=”OraDb12c_home1″

The execution of this should appear as follows:

[devenv01]/u01/app/oracle/product/12.1.0.2/db_1/oui/bin> ./runInstaller -silent -ignoreSysPrereqs -attachHome ORACLE_HOME=”/u01/app/oracle/product/10.2.0.4/db_1″ ORACLE_HOME_NAME=”OraDb10g_home1″

Starting Oracle Universal Installer…

Checking swap space: must be greater than 500 MB.   Actual 23750 MB    Passed

The inventory pointer is located at /var/opt/oracle/oraInst.loc

‘AttachHome’ was successful.

[devdb501]/u01/app/oracle/product/12.1.0.2/db_1/oui/bin> ORACLE_HOME_NAME=OraDb10g_home1

[devdb501]/u01/app/oracle/product/12.1.0.2/db_1/oui/bin> ./runInstaller -silent -ignoreSysPrereqs -attachHome ORACLE_HOME=”/u01/app/oracle/product/10.2.0.4/db_1″ ORACLE_HOME_NAME=”OraDb10g_home1″

[devdb501]/u01/app/oracle/product/12.1.0.2/db_1/oui/bin> ./runInstaller -silent -ignoreSysPrereqs -attachHome ORACLE_HOME=”/u01/app/oracle/product/11.2.0.4/db_1″ ORACLE_HOME_NAME=”OraDb11g_home1″

Starting Oracle Universal Installer…

Checking swap space: must be greater than 500 MB.   Actual 23817 MB    Passed

The inventory pointer is located at /var/opt/oracle/oraInst.loc

‘AttachHome’ was successful.

Checking the Inventory for each Oracle Home, we see that the process was successful. Any of the patches and information about the Inventory are returned with any opatch command. Here is an example of what you might see:

[devdb501]/home/oracle> $ORACLE_HOME/OPatch/opatch lsinventory

Oracle Interim Patch Installer version 12.1.0.1.7

Copyright (c) 2016, Oracle Corporation.  All rights reserved.

Oracle Home       : /u01/app/oracle/product/12.1.0.2/db_1

Central Inventory : /u01/app/oracle/oraInventory

from           : /u01/app/oracle/product/12.1.0.2/db_1/oraInst.loc

OPatch version    : 12.1.0.1.7

OUI version       : 12.1.0.2.0

Log file location : /u01/app/oracle/product/12.1.0.2/db_1/cfgtoollogs/opatch/opatch2016-01-25_11-26-44AM_1.log

 Lsinventory Output file location : /u01/app/oracle/product/12.1.0.2/db_1/cfgtoollogs/opatch/lsinv/lsinventory2016-01-25_11-26-44AM.txt

 Installed Top-level Products (1):

Oracle Database 12c                                                  12.1.0.2.0

There are 1 products installed in this Oracle Home.

 Interim patches (1) :

 Patch  20415564     : applied on Wed Jul 01 11:18:48 MDT 2015

Unique Patch ID:  18768682

Patch description:  “Database PSU 12.1.0.2.3, Oracle JavaVM Component (Apr2015)”

Created on 1 Apr 2015, 06:55:25 hrs PST8PDT

Bugs fixed:

19699946, 19909862, 19223010, 19877336, 19895326, 20408829, 19153980

20415564, 19855285, 19895362, 19231857, 19245191, 20408866

——————————————————————————–

 OPatch succeeded.

[devenv01]/home/oracle>

A stable database environment is the result of a clean and concise initial installation. Making certain your database has the latest patches installed is an essential part of the ongoing process of supporting that environment. Although it may seem time-consuming, a database professional needs to frequently make time to attend to documenting and fixing seemingly small issues as they are uncovered. This eliminates the probability for them to become large problems later.

We’ve previously offered other ideas for working with Oracle, including a webinar with Chuck Ezell on the value of conducting Oracle Health Checks. If you have questions about how to optimize your Oracle configuration, Datavail can work with you and your organization to effectively support your Oracle environment for your benefit and that of your clients and customers.

To learn more about our remote database services and how our experts can help with your ongoing Oracle operations, please contact Datavail to discuss a custom solution designed for your enterprise.

Contact Us
Chad Cleveland
Senior Oracle DBA
Chad Cleveland is an exciting and energetic individual with 15 years of experience in IT, including 9 years as an Oracle Database Administrator. He enjoys working with his customers to streamline and remediate Database Infrastructure in areas such as hardware migrations, Cluster (RAC) and database upgrades, and extensive monitoring solutions with Oracle Enterprise Manager.

Leave a Reply

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