{"id":1461,"date":"2016-11-21T09:41:23","date_gmt":"2016-11-21T07:41:23","guid":{"rendered":"http:\/\/www.ludovicocaldara.net\/dba\/?p=1461"},"modified":"2020-08-18T16:19:28","modified_gmt":"2020-08-18T14:19:28","slug":"getting-oracle-homes-from-orainventory","status":"publish","type":"post","link":"https:\/\/www.ludovicocaldara.net\/dba\/getting-oracle-homes-from-orainventory\/","title":{"rendered":"Getting the Oracle Homes in a server from the oraInventory"},"content":{"rendered":"<p>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.<\/p>\n<p>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).<\/p>\n<p><a href=\"https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2016\/11\/inventory_structure.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1462\" src=\"https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2016\/11\/inventory_structure.png\" alt=\"inventory_structure\" width=\"789\" height=\"396\" srcset=\"https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2016\/11\/inventory_structure.png 789w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2016\/11\/inventory_structure-300x151.png 300w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2016\/11\/inventory_structure-768x385.png 768w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2016\/11\/inventory_structure-500x251.png 500w\" sizes=\"auto, (max-width: 789px) 100vw, 789px\" \/><\/a>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).<\/p>\n<pre class=\"lang:sh decode:true \"># [ oracle@testlab:\/u01\/app\/oracle\/ [17:53:48] [12.1.0.2.0 EE SID=theludot] 0 ] #\r\n# type lsoh\r\nlsoh is a function\r\nlsoh ()\r\n{\r\n    CENTRAL_ORAINV=`grep ^inventory_loc \/etc\/oraInst.loc | awk -F= '{print $2}'`;\r\n    IFS='\r\n';\r\n    echo;\r\n    printf \"%-22s %-55s %-12s %-9s\\n\" HOME LOCATION VERSION EDITION;\r\n    echo ---------------------- ------------------------------------------------------- ------------ ---------;\r\n    for line in `grep \"&lt;HOME NAME=\" ${CENTRAL_ORAINV}\/ContentsXML\/inventory.xml 2&gt;\/dev\/null`;\r\n    do\r\n        unset ORAVERSION;\r\n        unset ORAEDITION;\r\n        OH=`echo $line | tr ' ' '\\n' | grep ^LOC= | awk -F\\\" '{print $2}'`;\r\n        OH_NAME=`echo $line | tr ' ' '\\n' | grep ^NAME= | awk -F\\\" '{print $2}'`;\r\n        comp_file=$OH\/inventory\/ContentsXML\/comps.xml;\r\n        comp_xml=`grep \"COMP NAME\" $comp_file | head -1`;\r\n        comp_name=`echo $comp_xml | tr ' ' '\\n' | grep ^NAME= | awk -F\\\" '{print $2}'`;\r\n        comp_vers=`echo $comp_xml | tr ' ' '\\n' | grep ^VER= | awk -F\\\" '{print $2}'`;\r\n        case $comp_name in\r\n            \"oracle.crs\")\r\n                ORAVERSION=$comp_vers;\r\n                ORAEDITION=GRID\r\n            ;;\r\n            \"oracle.sysman.top.agent\")\r\n                ORAVERSION=$comp_vers;\r\n                ORAEDITION=AGT\r\n            ;;\r\n            \"oracle.server\")\r\n                ORAVERSION=`grep \"PATCH NAME=\\\"oracle.server\\\"\" $comp_file 2&gt;\/dev\/null | tr ' ' '\\n' | grep ^VER= | awk -F\\\" '{print $2}'`;\r\n                ORAEDITION=\"DBMS\";\r\n                if [ -z \"$ORAVERSION\" ]; then\r\n                    ORAVERSION=$comp_vers;\r\n                fi;\r\n                ORAMAJOR=`echo $ORAVERSION |  cut -d . -f 1`;\r\n                case $ORAMAJOR in\r\n                    11 | 12)\r\n                        ORAEDITION=\"DBMS \"`grep \"oracle_install_db_InstallType\" $OH\/inventory\/globalvariables\/oracle.server\/globalvariables.xml 2&gt;\/dev\/null | tr ' ' '\\n' | grep VALUE | awk -F\\\" '{print $2}'`\r\n                    ;;\r\n                    10)\r\n                        ORAEDITION=\"DBMS \"`grep \"s_serverInstallType\" $OH\/inventory\/Components21\/oracle.server\/*\/context.xml 2&gt;\/dev\/null | tr ' ' '\\n' | grep VALUE | awk -F\\\" '{print $2}'`\r\n                    ;;\r\n                esac\r\n            ;;\r\n        esac;\r\n        [[ -n $ORAEDITION ]] &amp;&amp; printf \"%-22s %-55s %-12s %-9s\\n\" $OH_NAME $OH $ORAVERSION $ORAEDITION;\r\n    done;\r\n    echo\r\n}\r\n# [ oracle@testlab:\/u01\/app\/oracle\/sbin [17:53:48] [12.1.0.2.0 EE SID=theludot] 0 ] #\r\n# lsoh\r\n\r\nHOME                   LOCATION                                                VERSION      EDITION\r\n---------------------- ------------------------------------------------------- ------------ ---------\r\nOraHome12C             \/u01\/app\/oracle\/product\/12.1.0.2                        12.1.0.2.0   DBMS EE\r\nOraDb11g_home1         \/u01\/app\/oracle\/product\/11.2.0.4                        11.2.0.4.0   DBMS EE\r\nOraGI12Home1           \/u01\/app\/grid\/product\/grid                              12.1.0.2.0   GRID\r\nagent12c1              \/u01\/app\/oracle\/product\/agent12c\/core\/12.1.0.5.0        12.1.0.5.0   AGT<\/pre>\n<p>HTH<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/www.ludovicocaldara.net\/dba\/getting-oracle-homes-from-orainventory\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[326,3,52,330,132],"tags":[],"class_list":["post-1461","post","type-post","status-publish","format-standard","hentry","category-oracle","category-oracledb","category-12c","category-oracle-inst-upg","category-triblog"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/1461","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/comments?post=1461"}],"version-history":[{"count":4,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/1461\/revisions"}],"predecessor-version":[{"id":1466,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/1461\/revisions\/1466"}],"wp:attachment":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/media?parent=1461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/categories?post=1461"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/tags?post=1461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}