Friday, April 8, 2011

Fixing a corrupt or a cloned database 11g Oracle Inventory

DBA’s working with Oracle especially ERP applications are familiar with cloning environment on demand. The issue becomes tricky when you need to apply a database patch using Opatch for testing before moving it to production.
The Oracle Inventory is a critical part of oracle installation and created using OUI. This is useful when you what to find out what patches have been applied to the database, mostly during upgrades and patch applications.

When you run the command opatch lsinventory from the Opatch directory in the $ORACLE_HOME in a cloned environment you might see the output like below

applprod@gvaebsdb3:/u01/DEV3/apps/proddb/11.2.0/OPatch $ opatch lsinventory
Invoking OPatch 11.1.0.6.6
Oracle Interim Patch Installer version 11.1.0.6.6
Copyright (c) 2009, Oracle Corporation. All rights reserved
Oracle Home : /u01/DEV4/apps/proddb/11.2.0
Central Inventory : n/a
from :
OPatch version : 11.1.0.6.6
OUI version : 11.2.0.1.0
OUI location : /u01/DEV3/apps/proddb/11.2.0/oui
Log file location : n/a
Patch history file: /u01/DEV3/apps/proddb/11.2.0/cfgtoollogs/opatch/opatch_history.txt
OPatch cannot find a valid oraInst.loc file to locate Central Inventory.
OPatch failed with error code 104
applprod@gvaebsdb3:/u01/DEV3/apps/proddb/11.2.0/OPatch

or
Now check the status of the inventory
applprod@gvaebsdb3:/u01/DEV3/apps/proddb/11.2.0/OPatch $ opatch lsinventory
Invoking OPatch 11.1.0.6.6
Oracle Interim Patch Installer version 11.1.0.6.6
Copyright (c) 2009, Oracle Corporation. All rights reserved
Oracle Home : /u01/DEV4/apps/proddb/11.2.0
Central Inventory : n/a
Central Inventory : /home/applprod/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.1.0.6.6
OUI version : 11.2.0.1.0
OUI location : /u01/DEV3/apps/proddb/11.2.0/oui
Log file location : /u01/DEV3/apps/proddb/11.2.0//cfgtoollogs/opatch/opatch-2011_Apr_09_40-20-30-CET_Tue.log

LsInventory Session failed: OPatch failed to locate Central Inventory.
Possible causes are:
The Central Inventory is corrupted
The oraInst.loc file specified is not valid.

OPatch failed with error code 72

At times the Inventory location can become corrupt or might have changed due to architecture due to different file systems etc. this will cause Opatch to error out with error code 104 and can hamper the database patch application.

To fix a corrupted oracle inventory implicates at times moving it to a different location or editing ContentsXML and changing the ORACLE_HOME_NAME

applprod@gvaebsdb3:~ /home/applprod/oraInventory/ContentsXML



Then go the $ORACLE_HOME/oui/bin

Launch the repair as shown below .Note you should attached the correct ORACLE_HOME and ORACLE_HOME_NAME can be anything

applprod@gvaebsdb3:/u01/DEV3/apps/proddb/11.2.0/oui/bin $ ./runInstaller -silent -invPtrLoc "/etc/oraInst.loc" -attachHome ORACLE_HOME="/u01/DEV3/apps/proddb/11.2.0" ORACLE_HOME_NAME="Ora11g_home1"
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB. Actual 7954 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2011-04-08_11-32-32AM. Please wait ...applprod@gvaebsdb3:/u01/DEV3/apps/proddb/11.2.0/oui/bin $ The inventory pointer is located at /etc/oraInst.loc
The inventory is located at /home/applprod/oraInventory
'AttachHome' was successful.
applprod@gvaebsdb3:/u01/DEV3/apps/proddb/11.2.0/oui/bin