Quantcast
Channel: OracleBuffer
Viewing all articles
Browse latest Browse all 58

The unusual case of recreating Oracle (central) Inventory

$
0
0

It could be a rare situation, where your Oracle RDBMS inventory is corrupted or lost and you don’t have a copy of the inventory to restore it. As a standard process, we usually keep backup of the Oracle Inventory to avoid these scenarios. However, there could be a situation where the standard process is not followed (Inventory is not backed up) and you encountered the problem; where Oracle is saying it’s inventory is corrupted or missing.

How to get the Inventory recreated? Well, read on to find out!!

A small recap about Oracle Inventory:

Oracle provides two types type of Inventory to facilitate installation and maintenance of Oracle software.

1. Central Inventory
2. Oracle Home Inventory

Central Inventory:

Each and every Oracle Home installation has an associated Central inventory, where the information about all Oracle products installed on a particular hots are registered. The Location of the central inventory is controlled by the inventory pointer file (oraInst.loc). Typically each Oracle software installation would have its own central inventory controlled by the pointer file. However, it is possible to have a common central inventory shared by multiple Oracle software installation.

In the case of a common central inventory, whenever any read/write operation is performed on the central inventory for a particular Oracle software installation, the inventory gets locked and any read/write to common inventory for other Oracle software installation must wait until lock is released.

The central inventory file is named as inventory.xml.

Oracle Home Inventory (Local Inventory):

Apart from the central inventory, there is a local inventory which is located under each ORACLE_HOME. This inventory included information relevant to the specific ORACLE_HOME only. The local inventory is location is $ORACLE_HOME/inventory.

The local inventory contains multiple files, of which following are the most relevant files.

Components File: The components file named as comps.xml and is most crucial inventory file. This file contains information about all the components as well as interim patches installed in a Oracle Home. This file also contains information related to third party application like JRE required by different Oracle tools and components.

The location of components file is $ORACLE_HOME/inventory/ContentsXML/comps.xml

Home Properties File: This file contains the information about the node list, the local node name as well as the CRS flag for the Oracle home. In a shared home, the local node information is not present. This file also contains the following information:

GUID: This is the unique Global ID for a particular Oracle home.
ARU_ID: This is the unique machine platform ID. The patching and patchset application depends on this ID.
ARU_ID_DESCRIPTION: This is the platform description.

A sample properties file in a Linux X86-64 machine looks like the following.





   726250057.443706830
   
   
      226
      Linux x86-64
   
   
   
   

Recreating Inventory without backup:

Now, lets focus on recreating the inventory (if it is corrupted/lost) when the backup is not available. In the case, when the backup is not available for the inventory, we can only recreate the Central Inventory (inventory.xml).
There is no way of recreating the local inventory files(comps.xml) if the backup is not available. In that case, the only option is to reinstall the Oracle software.

Having said that, lets take a look as to how to recreate the central inventory.

Lets say my inventory is corrupted or missing and I am receiving following errors while running opatch.

[oracle@mylab ~]$ $ORACLE_HOME/OPatch/opatch lsinv
Oracle Interim Patch Installer version 12.1.0.1.3
Copyright (c) 2015, Oracle Corporation.  All rights reserved.

Oracle Home       : /app/oracle/db/12.1.2
Central Inventory : /app/oracle/oraInventory
   from           : /app/oracle/db/12.1.2/oraInst.loc
OPatch version    : 12.1.0.1.3
OUI version       : 12.1.0.2.0
Log file location : /app/oracle/db/12.1.2/cfgtoollogs/opatch/opatch2015-04-25_00-19-54AM_1.log

List of Homes on this system:

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

OPatch failed with error code 73

Upon checking, could see that the central inventory is missing.

[oracle@mylab ContentsXML]$ ls -lrt /app/oracle/oraInventory/ContentsXML/inventory.xml
ls: /app/oracle/oraInventory/ContentsXML/inventory.xml: No such file or directory

Oracle provides a very straight forward and easy way to recreate the central inventory using the Oracle Universal Installer (OUI). We can use the OUI script runInstaller with the -attachHome parameter to recreate the central inventory and get the Oracle Home registered there.

The OUI scripts are located under $ORACLE_HOME/oui/bin location.

The syntax for recreating the central inventory is

$ORACLE_HOME/oui/bin/runInstaller -silent -attachHome -invPtrLoc "{central_inv_ptr_file}"
ORACLE_HOME="{Oracle_Home_Location}" ORACLE_HOME_NAME="{Oracle_Home_Name}"
CLUSTER_NODES="{node,node2,..}" LOCAL_NODE="{node_name}"

The mandatory parameters are -attachHome, ORACLE_HOME and ORACLE_HOME_NAME.

Lets recreate the central inventory.

[oracle@mylab ~]$ echo $ORACLE_HOME
/app/oracle/db/12.1.2
[oracle@mylab ~]$ cd $ORACLE_HOME/oui/bin
[oracle@mylab bin]$ ./runInstaller -silent -ignoreSysPrereqs -attachHome ORACLE_HOME="/app/oracle/db/12.1.2" ORACLE_HOME_NAME="OraDB12Home1"
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 4094 MB    Passed
The inventory pointer is located at /etc/oraInst.loc
'AttachHome' was successful.

Lets verify, if the central inventory is recreated.

[oracle@mylab bin]$ $ORACLE_HOME/OPatch/opatch lsinv
Oracle Interim Patch Installer version 12.1.0.1.3
Copyright (c) 2015, Oracle Corporation.  All rights reserved.

Oracle Home       : /app/oracle/db/12.1.2
Central Inventory : /app/oracle/oraInventory
   from           : /app/oracle/db/12.1.2/oraInst.loc
OPatch version    : 12.1.0.1.3
OUI version       : 12.1.0.2.0
Log file location : /app/oracle/db/12.1.2/cfgtoollogs/opatch/opatch2015-04-25_00-25-54AM_1.log

Lsinventory Output file location : /app/oracle/db/12.1.2/cfgtoollogs/opatch/lsinv/lsinventory2015-04-25_00-25-54AM.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  19035573     : applied on Sat Apr 25 00:14:02 IST 2015
Unique Patch ID:  18110560
   Created on 1 Oct 2014, 22:30:35 hrs PST8PDT
   Bugs fixed:
     19035573
--------------------------------------------------------------------------------

OPatch succeeded.


[oracle@mylab ~]$ ls -lrt /app/oracle/oraInventory/ContentsXML/inventory.xml
-rw-rw---- 1 oracle dba 546 Apr 25 00:29 /app/oracle/oraInventory/ContentsXML/inventory.xml

Yes, it is now recreated. Too simple, isn’t it.
However, this is not possible if the local inventory is lost/corrupted without a VALID backup.

Note: If the central inventory is shared by multiple Oracle Home, we need to repeat the above mentioned step for each of the Oracle Home.

Conclusion:

Though there is a way to recreate the central inventory without a backup, there is no way to recreate local inventory without backup (unless we install a new ORACLE_HOME and patch it to the same level as the current ORACLE_HOME). Therefore, it is recommended to take periodic backup of the inventory files and specially prior to applying any patches to the Oracle Home.


Viewing all articles
Browse latest Browse all 58

Trending Articles