{"id":1714,"date":"2018-05-20T11:20:28","date_gmt":"2018-05-20T09:20:28","guid":{"rendered":"http:\/\/www.ludovicocaldara.net\/dba\/?p=1714"},"modified":"2020-08-18T16:09:05","modified_gmt":"2020-08-18T14:09:05","slug":"oh-mgmt-5","status":"publish","type":"post","link":"https:\/\/www.ludovicocaldara.net\/dba\/oh-mgmt-5\/","title":{"rendered":"Oracle Home Management &#8211; part 5: Oracle Home Inventory and Naming Conventions"},"content":{"rendered":"<p>Having the capability of managing multiple Oracle Homes is fundamental for the following reasons:<\/p>\n<ul>\n<li>Out-of-place patching: cloning and patching a new Oracle Home usually takes less downtime than stopping the DBs and patching in-place<\/li>\n<li>Better control of downtime windows: if the databases are consolidated on a single server, having multiple Oracle Homes allows moving and patching one database at a time instead of stopping everything and doing a \u201cbig bang\u201d patch.<\/li>\n<\/ul>\n<p>Make sure that you have a good set of scripts that help you to switch correctly from one environment to the other one. Personally, I recommend <a href=\"https:\/\/www.trivadis.com\/en\/trivadis-toolbox#basenv\">TVD-BasEnv<\/a>, as it is very powerful and supports OFA and non-OFA environments, but for this blog series I will show my personal approach.<\/p>\n<p><strong>Get your Home information from the Inventory!<\/strong><\/p>\n<p>I wrote a blog post sometimes ago that shows how to get the Oracle Homes from the Central Inventory (Using Bash, OK, not the right tool to query XML files, but you get the idea):<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"79gzxMrxJH\"><p><a href=\"https:\/\/www.ludovicocaldara.net\/dba\/getting-oracle-homes-from-orainventory\/\">Getting the Oracle Homes in a server from the oraInventory<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;Getting the Oracle Homes in a server from the oraInventory&#8221; &#8212; DBA survival BLOG\" src=\"https:\/\/www.ludovicocaldara.net\/dba\/getting-oracle-homes-from-orainventory\/embed\/#?secret=PjyaEGKaKR#?secret=79gzxMrxJH\" data-secret=\"79gzxMrxJH\" width=\"584\" height=\"329\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>With the same approach, you can have a script to SET your environment:<\/p>\n<pre class=\"lang:sh decode:true \">setoh ()\r\n{\r\n    SEARCH=${1:-\"_foo_\"};\r\n    if [ $SEARCH == \"ic\" ]; then\r\n\t\t# ic is a shortcut for the Instant Client...\r\n        OH=\/u01\/app\/oracle\/sbin\/instantclient_12_2\r\n        export VERSION=12.2.0.1\r\n        export ORACLE_HOME=$OH\r\n        export LD_LIBRARY_PATH=$ORACLE_HOME\r\n        export OH_NAME=instantclient_12_2\r\n        export ORACLE_VERSION=$VERSION\r\n        export PATH=$ORACLE_HOME:$DEFAULT_PATH\r\n        echo ORACLE_SID = $ORACLE_SID\r\n        echo ORACLE_VERSION = $ORACLE_VERSION\r\n        echo ORACLE_HOME = $ORACLE_HOME\r\n    else\r\n        CENTRAL_ORAINV=`grep ^inventory_loc \/etc\/oraInst.loc | awk -F= '{print $2}'`;\r\n        IFS='\r\n';\r\n        found=0;\r\n        for line in `grep \"&lt;HOME NAME=\" ${CENTRAL_ORAINV}\/ContentsXML\/inventory.xml 2&gt;\/dev\/null`;\r\n        do\r\n            if [ $found -eq 1 ]; then\r\n                continue;\r\n            fi;\r\n            unset ORACLE_VERSION;\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            if [ \"$SEARCH\" == \"$OH_NAME\" ]; then\r\n                found=1;\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                        ORACLE_VERSION=$comp_vers;\r\n                        ORAEDITION=GRID\r\n                    ;;\r\n                    \"oracle.sysman.top.agent\")\r\n                        ORACLE_VERSION=$comp_vers;\r\n                        ORAEDITION=AGT\r\n                    ;;\r\n                    \"oracle.server\")\r\n                        ORACLE_VERSION=`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 \"$ORACLE_VERSION\" ]; then\r\n                            ORACLE_VERSION=$comp_vers;\r\n                        fi;\r\n                        ORAMAJOR=`echo $ORACLE_VERSION |  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                export VERSION=$ORACLE_VERSION;\r\n                export ORACLE_HOME=$OH;\r\n                export LD_LIBRARY_PATH=$ORACLE_HOME\/lib;\r\n                export OH_NAME;\r\n                export ORACLE_VERSION;\r\n                export PATH=$ORACLE_HOME\/bin:$ORACLE_HOME\/OPatch:$DEFAULT_PATH;\r\n                echo ORACLE_SID = $ORACLE_SID;\r\n                echo ORACLE_VERSION = $ORACLE_VERSION;\r\n                echo ORACLE_HOME = $ORACLE_HOME;\r\n                continue;\r\n            fi;\r\n        done;\r\n        if [ $found -eq 0 ]; then\r\n            echo \"cannot find Oracle Home $1\";\r\n            false;\r\n        else\r\n            true;\r\n        fi;\r\n    fi\r\n}<\/pre>\n<p>It uses a different approach from the <em>oraenv<\/em> script privided by Oracle, where you set the environment based on the ORACLE_SID variable and getting the information from the oratab. My setoh function gets the Oracle Home name as input. Although you can convert it easily to set the environment for a specific ORACLE_SID, there are some reason why I like it:<\/p>\n<ul>\n<li>You can set the environment for an Oracle Home that it is not associated to any database (yet)<\/li>\n<li>You can set the environment for an upgrade to a new release without changing (yet) the oratab<\/li>\n<li>It works for OMS, Grid and Agent homes as well&#8230;<\/li>\n<li>Most important, it will let you specify correctly the environment when you need to use a\u00a0 fresh install (for patching it as well)<\/li>\n<\/ul>\n<p>So, this is how it works:<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true\"># [ oracle@myserver:\/u01\/app\/oracle [11:23:18] [12.1.0.2.0 SID=\"not set\"] 0 ] #\r\n# lsoh\r\n\r\nHOME                        LOCATION                                                VERSION      EDITION\r\n--------------------------- ------------------------------------------------------- ------------ ---------\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\r\nOraDb11g_home1              \/u01\/app\/oracle\/product\/11.2.0.4                        11.2.0.4.0   DBMS EE\r\nOraDB12Home1                \/u01\/app\/oracle\/product\/12.1.0.2                        12.1.0.2.0   DBMS EE\r\n12_1_0_2_BP170718_RON       \/u01\/app\/oracle\/product\/12_1_0_2_BP170718_RON           12.1.0.2.0   DBMS EE\r\n12_1_0_2_BP180116_OCW       \/u01\/app\/oracle\/product\/12_1_0_2_BP180116_OCW           12.1.0.2.0   DBMS EE\r\n\r\n# [ oracle@myserver:\/u01\/app\/oracle [11:23:22] [12.1.0.2.0 SID=\"not set\"] 0 ] #\r\n# setoh 12_1_0_2_BP180116_OCW\r\nORACLE_SID =\r\nORACLE_VERSION = 12.1.0.2.0\r\nORACLE_HOME = \/u01\/app\/oracle\/product\/12_1_0_2_BP180116_OCW\r\n\r\n# [ oracle@myserver:\/u01\/app\/oracle [11:23:25] [12.1.0.2.0 SID=\"not set\"] 0 ] #\r\n# opatch lspatches\r\n26925218;OCW Patch Set Update : 12.1.0.2.180116 (26925218)\r\n26925263;Database Bundle Patch : 12.1.0.2.180116 (26925263)\r\n22243983;\r\n\r\nOPatch succeeded.<\/pre>\n<p>In the previous example, there are two Database homes that have been installed without a specific naming convention (OraDb11g_home1, OraDB12Home1) and two that follow a specific one (12_1_0_2_BP170718_RON, 12_1_0_2_BP180116_OCW).<\/p>\n<p><strong>Naming conventions play an important role<\/strong><\/p>\n<p>If you want to achieve an effective Oracle Home management, it is important that you have everywhere the same ORACLE_HOME paths, names and patch levels.<\/p>\n<p>The Oracle Home path should not include only the release number:<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true \">\/u01\/app\/oracle\/product\/12.1.0.2<\/pre>\n<p>If we have many Oracle Homes with the same release, how shall we call the other ones? There are several variables that might influence the naming convention:<\/p>\n<p>Edition (EE, SE), RAC Option or other options, the patch type (formerly PSU, BP: now RU and RUR), eventual additional one-off patches.<\/p>\n<p>Some ideas might be:<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true\">\/u01\/app\/oracle\/product\/EE12.1.0.2\r\n\/u01\/app\/oracle\/product\/EE12.1.0.2_BP171019\r\n\/u01\/app\/oracle\/product\/EE12.1.0.2_BP171019_v2<\/pre>\n<p>The new release model will facilitate a lot the definition of a naming convention as we will have names like:<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true\">\/u01\/app\/oracle\/product\/EE18.1.0\r\n\/u01\/app\/oracle\/product\/EE18.2.1\r\n\/u01\/app\/oracle\/product\/EE18.2.1_v2<\/pre>\n<p>Of course, the naming convention is not universal and can be adapted depending on the customer (e.g., if you have only Enterprise Editions you might omit this information).<\/p>\n<p><strong>Replacing dots with underscores?<\/strong><\/p>\n<p>You will see, at the end of the series, that I use Oracle Home paths with underscores instead of dots:<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true\">\/u01\/app\/oracle\/product\/EE12_1_0_2\r\n\/u01\/app\/oracle\/product\/EE12_1_0_2_BP171019\r\n\/u01\/app\/oracle\/product\/EE12_1_0_2_BP171019_v2<\/pre>\n<p>Why?<\/p>\n<p>From a naming perspective, there is no need to have the Home that corresponds to the release number. Release, version and product information can be collected through the inventory.<\/p>\n<p>What is really important is to have good naming conventions and good manageability. In my ideal world, the Oracle Home name inside the central inventory and the basename of the Oracle Home path are the same: this facilitates tremendously the scripting of the Oracle Home provisioning.<\/p>\n<p>Sadly, the Oracle Home name cannot contain dots, it is a limitation of the Oracle Inventory, here&#8217;s why I replaced them with underscores.<\/p>\n<p>In the next blog post, I will show how to plan a framework for automated Oracle Home provisioning.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Having the capability of managing multiple Oracle Homes is fundamental for the following reasons: Out-of-place patching: cloning and patching a new Oracle Home usually takes less downtime than stopping the DBs and patching in-place Better control of downtime windows: if &hellip; <a href=\"https:\/\/www.ludovicocaldara.net\/dba\/oh-mgmt-5\/\">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":[321,336,326,3,330,132],"tags":[],"class_list":["post-1714","post","type-post","status-publish","format-standard","hentry","category-aced","category-devops","category-oracle","category-oracledb","category-oracle-inst-upg","category-triblog"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/1714","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=1714"}],"version-history":[{"count":8,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/1714\/revisions"}],"predecessor-version":[{"id":1785,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/1714\/revisions\/1785"}],"wp:attachment":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/media?parent=1714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/categories?post=1714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/tags?post=1714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}