Recently, we upgraded the database, as part of upgrade and which gave us error. The issue was additional “/” which caused the problem for us. Database connect failed with: ORA-12547: TNS:lost contact (DBD ERROR: OCIServerAttach) Here we had to recreate central inventory before upgrading the database. Here we are “How to recreate Central Inventory in Oracle.”
Table of Contents
Introduction
We usually get this issue when you take the handover of old databases which is not managed by a DBA. In our case issue came because of this. Previously, the server managed by application team. Today it was released to us for upgrading the database. Now since we were upgrading we wanted to check the Opatch lsinventory and it didn’t work for us. Corruption in Central Inventory. Now I had only one option to recreate the central inventory.
What is Central Inventory in Oracle
Oracle stores information about all the oracle products installed in all the oracle homes on same server. Inventory is stored in XML format only as it is said it is faster loading of the data. One can find the central Inventory in oracle by –
Firstly, you have to look for oracle inventory pointer file which will tell you the location of central inventory. In other words, One file contains the location of oracle inventory which is called Oracle Inventory Pointer File. file will have location of the Central Inventory in oracle. However, each Platform has different location for the oracle inventory pointer file.
For Windows -->
1)You need to go to Run ( windows + R)
2)Type regedit
3)Expand HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE
4)Check the value for "inst_loc"
For Linux/AIX -->
cat /etc/oraInst.loc
--> inventory_loc parameter will tell you the location of the central inventory
For Sun Solaris -->
/var/opt/oracle/oraInst.loc
--> inventory_loc parameter will tell you the location of the central inventory
For instance, Let me share my personal machine’s oraInst.loc
[oracledbworld@localhost OPatch]$ cat /etc/oraInst.loc
inventory_loc=/oracle/app/oraInventory
inst_group=oracledbworld
For instance,lets see the Content of central Inventory –
[oracledbworld@localhost ContentsXML]$ ls -ltr
total 12
-rw-rw----. 1 oracledbworld oracledbworld 488 Jul 1 05:49 inventory.xml
-rw-rw----. 1 oracledbworld oracledbworld 329 Jul 1 05:49 comps.xml
-rw-rw----. 1 oracledbworld oracledbworld 292 Jul 1 05:49 libs.xml
[oracledbworld@localhost ContentsXML]$
[oracledbworld@localhost ContentsXML]$
[oracledbworld@localhost ContentsXML]$ pwd
/oracle/app/oraInventory/ContentsXML
[oracledbworld@localhost ContentsXML]$
--------------------------------------------------------------------------
[oracledbworld@localhost ContentsXML]$ cat inventory.xml
<?xml version="1.0" standalone="yes" ?>
<!-- Copyright (c) 1999, 2020, Oracle and/or its affiliates.
All rights reserved. -->
<!-- Do not modify the contents of this file by hand. -->
<INVENTORY>
<VERSION_INFO>
<SAVED_WITH>12.2.0.1.4</SAVED_WITH>
<MINIMUM_VER>2.1.0.6.0</MINIMUM_VER>
</VERSION_INFO>
<HOME_LIST>
<HOME NAME="OraDB12Home1" LOC="/oracle/app/oracledbworld/product/12.2.0/dbhome_1" TYPE="O" IDX="1"/>
</HOME_LIST>
<COMPOSITEHOME_LIST>
</COMPOSITEHOME_LIST>
</INVENTORY>
------------------------------------------------------------------------
[oracledbworld@localhost ContentsXML]$ cat comps.xml
<?xml version="1.0" standalone="yes" ?>
<!-- Copyright (c) 1999, 2020, Oracle and/or its affiliates.
All rights reserved. -->
<!-- Do not modify the contents of this file by hand. -->
<PRD_LIST>
<TL_LIST>
</TL_LIST>
<COMP_LIST>
</COMP_LIST>
<ONEOFF_LIST>
</ONEOFF_LIST>
<PATCHSET_UPDATE_LIST>
</PATCHSET_UPDATE_LIST>
</PRD_LIST>
[oracledbworld@localhost ContentsXML]$
[oracledbworld@localhost ContentsXML]$
------------------------------------------------------------------------
[oracledbworld@localhost ContentsXML]$ cat libs.xml
<?xml version="1.0" standalone="yes" ?>
<!-- Copyright (c) 1999, 2020, Oracle and/or its affiliates.
All rights reserved. -->
<!-- Do not modify the contents of this file by hand. -->
<LIB_LIST>
<QUERY_LIST>
</QUERY_LIST>
<DIALOG_LIST>
</DIALOG_LIST>
<ACTION_LIST>
</ACTION_LIST>
</LIB_LIST>
[oracledbworld@localhost ContentsXML]$
How to recreate Central Inventory in Oracle
Below output will shows the output corrupted central inventory.
[oracledbworld@localhost OPatch]$ ./opatch lsinventory
Oracle Interim Patch Installer version 12.2.0.1.6
Can not get details for given Oracle Home
LsInventory: OPatch Exception while accessing O2O
OPATCH_JAVA_ERROR : An exception of type "OPatchException" has occurred:
OPatch Exception:
Can not get details for given Oracle Home
Oracle interim Patch Installer version 12.2.0.3.0
OPatch failed to locate Central Inventory.
Possible causes are:
The Central Inventory is corrupted
The oraInst.loc file specified is not valid.
Below it shows issue faced identify the location of central inventory –
[oracledbworld@localhost OPatch]$ ./opatch lsinventory
Oracle Interim Patch Installer version 12.2.0.1.6
Copyright (c) 2020, Oracle Corporation. All rights reserved.
Oracle Home : /oracle/app/oracledbworld/product/12.2.0/dbhome_1
Central Inventory : n/a
from :
OPatch version : 12.2.0.1.6
OUI version : 12.2.0.1.4
Log file location : n/a
OPatch cannot find a valid oraInst.loc file to locate Central Inventory.
OPatch failed with error code 104
[oracledbworld@localhost OPatch]$
Lets recreate the oracle central inventory
- Create a new location –>
mkdir /oracle/app/oraInventory
chmod 755 /oracle/app/oraInventory
2. After that, Edit /var/opt/oracle/oraInst.loc or /etc/oraInst.loc depending upon platform.
[oracledbworld@localhost OPatch]$ cat /etc/oraInst.loc
inventory_loc=/oracle/app/oraInventory
inst_group=oracledbworld
3. After that, Run following command –>
cd $ORACLE_HOME/oui/bin
./runInstaller -silent -ignoreSysPrereqs -attachHome ORACLE_HOME="<Oracle_Home_Location>" ORACLE_HOME_NAME="<Name_Of _Oracle_Home>"
So in my case
./runInstaller -silent -ignoreSysPrereqs -attachHome ORACLE_HOME="/oracle/app/oracledbworld/product/12.2.0/dbhome_1" ORACLE_HOME_NAME="OraDB12Home1"
In my case we have only one database home hence I registered only one. If you have multiple Oracle home and you want to register then, you might have to run 3 command for all oracle home.
You can check the location of logs of the attachment –>
/oracle/app/oraInventory/logs/AttachHome2020-07-01_04-32-53AM.log
Once this is completed you can fire following command and check if everything is working fine for you.
[oracledbworld@localhost OPatch]$ ./opatch lsinventory
Oracle Interim Patch Installer version 12.2.0.1.6
Copyright (c) 2020, Oracle Corporation. All rights reserved.
Oracle Home : /oracle/app/oracledbworld/product/12.2.0/dbhome_1
Central Inventory : /oracle/app/oraInventory
from : /oracle/app/oracledbworld/product/12.2.0/dbhome_1/oraInst.loc
OPatch version : 12.2.0.1.6
OUI version : 12.2.0.1.4
Log file location : /oracle/app/oracledbworld/product/12.2.0/dbhome_1/cfgtoollogs/opatch/opatch2020-07-12_12-09-11PM_1.log
Lsinventory Output file location : /oracle/app/oracledbworld/product/12.2.0/dbhome_1/cfgtoollogs/opatch/lsinv/lsinventory2020-07-12_12-09-11PM.txt
--------------------------------------------------------------------------------
Local Machine Information::
Hostname: localhost
ARU platform id: 226
ARU platform description:: Linux x86-64
Installed Top-level Products (1):
Oracle Database 12c 12.2.0.1.0
There are 1 products installed in this Oracle Home.
There are no Interim patches installed in this Oracle Home.
--------------------------------------------------------------------------------
OPatch succeeded.
[oracledbworld@localhost OPatch]$
In addition to this let me share how commands changes for windows.
Similarly create new folder.
After that, you need to fire following command –>
setup.exe -silent -ignoreSysPrereqs -attachHome ORACLE_HOME="<Oracle_Home_Location>" ORACLE_HOME_NAME="<Name_Of _Oracle_Home>"
Once completed, you need to run the opatch lsinventory to crosscheck the same.
Thanks for reading 🙂
Reference – support.oracle.com
good info