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)
- Far Sync and Fast-Start Failover Protection modes - April 14, 2022
- Can a physical standby database receive the redo SYNC if the Far Sync instance fails? - April 7, 2022
- Can I rename a PDB in a Data Guard configuration? - November 21, 2021
Pingback: Getting the Oracle Homes in a server from the oraInventory - Ludovico Caldara - Blogs - triBLOG
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 🙂
Hi Ludovico,
How do i run it
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
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.
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 🙂