The information contained in the oratab should always be updated, but it is not always reliable. If you want to know what Oracle installations you have in a server, better to get it from the Oracle Universal Installer or, if you want some shortcuts, do some grep magics inside the inventory with the shell.
The following diagram is a simplified structure of the inventory that shows what entries are present in the central inventory (one per server) and the local inventories (one per Oracle Home).
You can use this simple function to get some content out of it, including the edition (that information is a step deeper in the local inventory).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# [ oracle@testlab:/u01/app/oracle/ [17:53:48] [12.1.0.2.0 EE SID=theludot] 0 ] # # type lsoh lsoh is a function lsoh () { CENTRAL_ORAINV=`grep ^inventory_loc /etc/oraInst.loc | awk -F= '{print $2}'`; IFS=' '; echo; printf "%-22s %-55s %-12s %-9s\n" HOME LOCATION VERSION EDITION; echo ---------------------- ------------------------------------------------------- ------------ ---------; for line in `grep "<HOME NAME=" ${CENTRAL_ORAINV}/ContentsXML/inventory.xml 2>/dev/null`; do unset ORAVERSION; unset ORAEDITION; OH=`echo $line | tr ' ' '\n' | grep ^LOC= | awk -F\" '{print $2}'`; OH_NAME=`echo $line | tr ' ' '\n' | grep ^NAME= | awk -F\" '{print $2}'`; comp_file=$OH/inventory/ContentsXML/comps.xml; comp_xml=`grep "COMP NAME" $comp_file | head -1`; comp_name=`echo $comp_xml | tr ' ' '\n' | grep ^NAME= | awk -F\" '{print $2}'`; comp_vers=`echo $comp_xml | tr ' ' '\n' | grep ^VER= | awk -F\" '{print $2}'`; case $comp_name in "oracle.crs") ORAVERSION=$comp_vers; ORAEDITION=GRID ;; "oracle.sysman.top.agent") ORAVERSION=$comp_vers; ORAEDITION=AGT ;; "oracle.server") ORAVERSION=`grep "PATCH NAME=\"oracle.server\"" $comp_file 2>/dev/null | tr ' ' '\n' | grep ^VER= | awk -F\" '{print $2}'`; ORAEDITION="DBMS"; if [ -z "$ORAVERSION" ]; then ORAVERSION=$comp_vers; fi; ORAMAJOR=`echo $ORAVERSION | cut -d . -f 1`; case $ORAMAJOR in 11 | 12) ORAEDITION="DBMS "`grep "oracle_install_db_InstallType" $OH/inventory/globalvariables/oracle.server/globalvariables.xml 2>/dev/null | tr ' ' '\n' | grep VALUE | awk -F\" '{print $2}'` ;; 10) ORAEDITION="DBMS "`grep "s_serverInstallType" $OH/inventory/Components21/oracle.server/*/context.xml 2>/dev/null | tr ' ' '\n' | grep VALUE | awk -F\" '{print $2}'` ;; esac ;; esac; [[ -n $ORAEDITION ]] && printf "%-22s %-55s %-12s %-9s\n" $OH_NAME $OH $ORAVERSION $ORAEDITION; done; echo } # [ oracle@testlab:/u01/app/oracle/sbin [17:53:48] [12.1.0.2.0 EE SID=theludot] 0 ] # # lsoh HOME LOCATION VERSION EDITION ---------------------- ------------------------------------------------------- ------------ --------- OraHome12C /u01/app/oracle/product/12.1.0.2 12.1.0.2.0 DBMS EE OraDb11g_home1 /u01/app/oracle/product/11.2.0.4 11.2.0.4.0 DBMS EE OraGI12Home1 /u01/app/grid/product/grid 12.1.0.2.0 GRID agent12c1 /u01/app/oracle/product/agent12c/core/12.1.0.5.0 12.1.0.5.0 AGT |
HTH
The following two tabs change content below.
Latest posts by Ludovico (see all)
- New views in Oracle Data Guard 23c - January 3, 2024
- New in Data Guard 21c and 23c: Automatic preparation of the primary - December 22, 2023
- Does FLASHBACK QUERY work across incarnations or after a Data Guard failover? - December 13, 2023
Hi Thomas,
Regarding the grep errors: it looks like there are some homes registered in the central inventory that have been removed manually. Possible?
Regarding EM13: I can’t remember if I tested it. Probably something to change in the script. :-/
Thanks for the script, I have executed the function and it works great. I have executed on Solaris. However the script did not displayed 13c EM agent home. Am I missing anything here.
#contents.xml#
-lsoh output
HOME LOCATION VERSION EDITION
———————- ——————————————————- ———— ———
grep: can’t open /u01/app/oracle/product/12102/emagent/plugins/oracle.sysman.oh.discovery.plugin_12.1.0.5.0/inventory/ContentsXML/comps.xml
grep: can’t open /u01/app/oracle/product/12102/emagent/plugins/oracle.sysman.vi.discovery.plugin_12.1.0.2.0/inventory/ContentsXML/comps.xml
grep: can’t open /u01/app/oracle/product/12102/emagent/plugins/oracle.sysman.emas.discovery.plugin_12.1.0.8.0/inventory/ContentsXML/comps.xml
grep: can’t open /u01/app/oracle/product/12102/emagent/sbin/inventory/ContentsXML/comps.xml
grep: can’t open /u01/app/oracle/product/12102/emagent/plugins/oracle.sysman.oh.agent.plugin_12.1.0.5.0/inventory/ContentsXML/comps.xml
grep: can’t open /u01/app/oracle/product/12102/emagent/plugins/oracle.sysman.db.agent.plugin_12.1.0.8.0/inventory/ContentsXML/comps.xml
grep: can’t open /u01/app/oracle/product/12102/emagent/plugins/oracle.sysman.xa.discovery.plugin_12.1.0.6.0/inventory/ContentsXML/comps.xml
OraDb11g_home1 /u01/app/oracle/product/11.2.0.2/db 11.2.0.2.0 DBMS EE
OraDb11g_home2 /u01/app/oracle/product/11.2.0.3/db 11.2.0.3.0 DBMS EE
grep: can’t open /u01/app/oracle/product/12102/emagent/plugins/oracle.sysman.db.discovery.plugin_12.1.0.8.0/inventory/ContentsXML/comps.xml
grep: can’t open /u01/app/oracle/product/12102/emagent/core/12.1.0.5.0/inventory/ContentsXML/comps.xml
Is there a way to tell if its RDBMS home, a client install or GI or goldengate….I do not want to depend on the home name.
Yes, that’s what it does… just read the code 🙂
Great script
I added a test to manage additional Cloud Control 12c agent plugins which interfere with script :
if [ -f $comp_file ] ; then <= between line 18 and 19
fi <= between line 47 and 48
Thanks Chris.
If you like this kind of scripts, you might check its evolution here:
https://github.com/ludovicocaldara/COE
Hi Ludovico,
How do i run it
Raj, copy the definition of the function in a script and source it in your .bash_profile … then you should have your lsoh function available in your shell.
Great script.
I added one small change to ignore detached/removed oracle homes.
At line 11 when doing a grep for list of oracle homes:
grep -v “REMOVED=\”T\””
Regards,
Mitja
Great, thank you for the update 🙂
Pingback: Getting the Oracle Homes in a server from the oraInventory - Ludovico Caldara - Blogs - triBLOG