{"id":1882,"date":"2019-07-12T11:54:47","date_gmt":"2019-07-12T09:54:47","guid":{"rendered":"http:\/\/www.ludovicocaldara.net\/dba\/?p=1882"},"modified":"2020-08-18T16:00:31","modified_gmt":"2020-08-18T14:00:31","slug":"cman-oci-install","status":"publish","type":"post","link":"https:\/\/www.ludovicocaldara.net\/dba\/cman-oci-install\/","title":{"rendered":"Install and configure CMAN 19c in the Oracle Cloud, step by step"},"content":{"rendered":"<p>Installing and configuring CMAN is a trivial activity, but having the steps in one place is better than reinventing the wheel.<\/p>\n<p><strong>Prepare for the install<\/strong><\/p>\n<p>Download the Oracle Client 19.3.0.0 in the <a href=\"https:\/\/www.oracle.com\/technetwork\/database\/enterprise-edition\/downloads\/oracle19c-linux-5462157.html\">Oracle Database 19c download page<\/a>.<\/p>\n<p>Choose this one: <a id=\"file6\" class=\"boldbodylink\" href=\"https:\/\/download.oracle.com\/otn\/linux\/oracle19c\/190000\/LINUX.X64_193000_client.zip\" name=\"file6\">LINUX.X64_193000_client.zip<\/a> (64-bit) (1,134,912,540 bytes) , not the one named &#8220;LINUX.X64_193000_client_home.zip&#8221; because it is a preinstalled home that does not contain the CMAN tools.<\/p>\n<p>Access the OCI Console and create a new Compute instance. The default\u00a0 configuration is OK, just make sure that it is Oracle Linux 7 \ud83d\ude42<\/p>\n<p>Do not forget to add your SSH Public Key to access the VM via SSH!<\/p>\n<p>Access the VM using<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true\">ssh opc@{public_ip}<\/pre>\n<p>Copy the Oracle Client zip in \/tmp using your favorite scp program.<\/p>\n<p><strong>Install CMAN<\/strong><\/p>\n<p>Follow these steps to install CMAN:<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true\"># become root\r\nsudo su - root\r\n\r\n# install some prereqs (packages, oracle user, kernel params, etc.):\r\nyum install oracle-database-preinstall-19c.x86_64\r\n\r\n# prepare the base directory:\r\nmkdir \/u01\r\nchown oracle:oinstall \/u01\r\n\r\n# become oracle\r\nsu - oracle\r\n\r\n# prepare the Oracle Home dir\r\nmkdir -p \/u01\/app\/oracle\/product\/cman1930\r\n\r\n# unzip the Client install binaries\r\nmkdir -p $HOME\/stage\r\ncd $HOME\/stage\r\nunzip \/tmp\/LINUX.X64_193000_client.zip\r\n\r\n# prepare the response file:\r\ncat &lt;&lt;EOF &gt; $HOME\/cman.rsp\r\noracle.install.responseFileVersion=\/oracle\/install\/rspfmt_clientinstall_response_schema_v19.0.0\r\nORACLE_HOSTNAME=$(hostname)\r\nUNIX_GROUP_NAME=oinstall\r\nINVENTORY_LOCATION=\/u01\/app\/oraInventory\r\nSELECTED_LANGUAGES=en\r\nORACLE_HOME=\/u01\/app\/oracle\/product\/cman1930\r\nORACLE_BASE=\/u01\/app\/oracle\r\noracle.install.client.installType=Custom\r\noracle.install.client.customComponents=\"oracle.sqlplus:19.0.0.0.0\",\"oracle.network.client:19.0.0.0.0\",\"oracle.network.cman:19.0.0.0.0\",\"oracle.network.listener:19.0.0.0.0\"\r\nEOF\r\n\r\n# install!\r\n$HOME\/stage\/client\/runInstaller -silent -responseFile $HOME\/cman.rsp  ORACLE_HOME_NAME=cman1930\r\n\r\n# back as root:\r\nexit\r\n\r\n# finish the install\r\n\/u01\/app\/oraInventory\/orainstRoot.sh\r\n\/u01\/app\/oracle\/product\/cman1930\/root.sh\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Basic configuration<\/strong><\/p>\n<pre class=\"lang:plsql decode:true \"># as oracle:\r\n\r\nmkdir -p \/u01\/app\/oracle\/network\/admin\r\nexport TNS_ADMIN=\/u01\/app\/oracle\/network\/admin\r\n\r\ncat &lt;&lt;EOF &gt; $TNS_ADMIN\/cman-test.ora\r\ncman-test = (configuration=\r\n  (address=(protocol=tcp)(host=$(hostname))(port=1521))\r\n  (parameter_list =\r\n    (log_level=ADMIN)\r\n    (max_connections=1024)\r\n    (idle_timeout=0)\r\n    (registration_invited_nodes = *)\r\n    (inbound_connect_timeout=0)\r\n    (session_timeout=0)\r\n    (outbound_connect_timeout=0)\r\n    (max_gateway_processes=16)\r\n    (min_gateway_processes=2)\r\n    (remote_admin=on)\r\n    (trace_level=off)\r\n    (max_cmctl_sessions=4)\r\n    (event_group=init_and_term,memory_ops)\r\n  )\r\n  (rule_list=\r\n    (rule=\r\n       (src=*)(dst=*)(srv=*)(act=accept)\r\n       (action_list=(aut=off)(moct=0)(mct=0)(mit=0)(conn_stats=on))\r\n  ) )\r\n)\r\nEOF\r\n\r\necho \"IFILE=${TNS_ADMIN}\/cman-test.ora\" &gt;&gt; $TNS_ADMIN\/cman.ora\r\n<\/pre>\n<p>This will create a CMAN configuration named <strong>cman-test<\/strong>. Beware that it is very basic and insecure. Please read the CMAN documentation if you want something more secure or sophisticated.<\/p>\n<p>The advantage of having the TNS_ADMIN outside the Oracle Home is that if you need to patch CMAN, you can do it out-of-place without the need to copy the configuration files somewhere else.<\/p>\n<p>The advantage of using IFILE inside cman.ora, is that you can manage easily different CMAN configurations in the same host without editing directly cman.ora, with the risk of messing it up.<\/p>\n<p><strong>Preparing the start\/stop script<\/strong><\/p>\n<p>Create a file<strong> \/u01\/app\/oracle\/scripts\/cman_service.sh\u00a0<\/strong>with this content:<\/p>\n<pre class=\"lang:sh decode:true \">#!\/bin\/bash -l\r\n\r\nLOCAL_PARSE_OPTIONS=\"a:c:o:\"\r\n\r\nUsage () {\r\n        cat &lt;&lt;EOF\r\n\r\n        Purpose   : Start\/stop a CMAN configuration\r\n\r\n        Usage: `basename $0` -a {start|stop|reload|restart|status} -c &lt;config_name&gt; -o &lt;oracle_home&gt;\r\n\r\n        Options:\r\n                -a action           One in start|stop|reload|restart|status\r\n                -c config_name      Name of the cman instance (e.g. ais-prod, gen-prod, etc.)\r\n                -o oracle_home      The ORACLE_HOME path that must be used for the operation (e.g. cman1930)\r\nEOF\r\n}\r\n\r\n\r\nCENTRAL_CONFIG_DIR=\/ORA\/dbs01\/oracle\/network\/admin\r\n\r\nwhile getopts \":${LOCAL_PARSE_OPTIONS}\" opt ; do\r\n        case $opt in\r\n                a)\r\n                        L_Action=$OPTARG\r\n                        ;;\r\n                c)\r\n                        L_Config=$OPTARG\r\n                        ;;\r\n                o)\r\n                        L_OH=$OPTARG\r\n                        ;;\r\n                \\?)\r\n                        eerror \"Invalid option: -$OPTARG\"\r\n                        exit 1\r\n                        ;;\r\n                :)\r\n                        eerror \"Option -$OPTARG requires an argument.\"\r\n                        exit 1\r\n                        ;;\r\n        esac\r\ndone\r\n\r\nif [ ! $L_Config ] ; then\r\n    Usage\r\n        eerror \"Please specify a configuration name with -c. Possible values are: \"\r\n        ls -1 $CENTRAL_CONFIG_DIR | sed -e \"s\/\\.ora\/\/\" | grep -v cman\r\n        exit 1\r\nfi\r\n\r\n\r\n## if the install step was OK, we should have a valid OH installed with this name:\r\nexport ORACLE_HOME=$L_OH\r\nif [ ! -f $ORACLE_HOME\/bin\/cmctl ] ; then\r\n        Usage\r\n        echo \"Please set a valid ORACLE_HOME name with -o.\"\r\n        exit 1\r\nfi\r\n\r\n\r\nexport TNS_ADMIN=$CENTRAL_CONFIG_DIR\r\ncase $L_Action in\r\n        start)\r\n                $OH\/bin\/cmctl startup -c $L_Config\r\n                ;;\r\n        stop)\r\n                $OH\/bin\/cmctl shutdown -c $L_Config\r\n                ;;\r\n        reload)\r\n                $OH\/bin\/cmctl reload -c $L_Config\r\n                ;;\r\n        restart)\r\n                $OH\/bin\/cmctl shutdown -c $L_Config\r\n                sleep 1\r\n                $OH\/bin\/cmctl startup -c $L_Config\r\n                ;;\r\n        status)\r\n                $OH\/bin\/cmctl show status -c $L_Config\r\n                # do it again for the exit code\r\n                $OH\/bin\/cmctl show status -c $L_Config | grep \"The command completed successfully.\" &gt;\/dev\/null\r\n                ;;\r\n        *)\r\n                echo \"Invalid action\"\r\n                exit 1\r\n                ;;\r\nesac<\/pre>\n<p>This is at the same time ORACLE_HOME agnostic and configuration agnostic.<\/p>\n<p>Make it executable:<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true \">chmod +x \/u01\/app\/oracle\/scripts\/cman_service.sh<\/pre>\n<p>and try to start CMAN:<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true\">$ \/u01\/app\/oracle\/scripts\/cman_service.sh -o \/u01\/app\/oracle\/product\/cman1930 -c cman-test -a start\r\nVERSION         = 19.3.0.0.0\r\nORACLE_HOME     = \/u01\/app\/oracle\/product\/cman1930\r\nVERSION         = 19.3.0.0.0\r\nORACLE_HOME     = \/u01\/app\/oracle\/product\/cman1930\r\n\r\nCMCTL for Linux: Version 19.0.0.0.0 - Production on 12-JUL-2019 09:23:50\r\n\r\nCopyright (c) 1996, 2019, Oracle.  All rights reserved.\r\n\r\nCurrent instance cman-test is not yet started\r\nConnecting to (DESCRIPTION=(address=(protocol=tcp)(host=ocf-cman-1)(port=1521)))\r\nStarting Oracle Connection Manager instance cman-test. Please wait...\r\nCMAN for Linux: Version 19.0.0.0.0 - Production\r\nStatus of the Instance\r\n----------------------\r\nInstance name             cman-test\r\nVersion                   CMAN for Linux: Version 19.0.0.0.0 - Production\r\nStart date                12-JUL-2019 09:23:50\r\nUptime                    0 days 0 hr. 0 min. 9 sec\r\nNum of gateways started   2\r\nAverage Load level        0\r\nLog Level                 ADMIN\r\nTrace Level               OFF\r\nInstance Config file      \/u01\/app\/oracle\/product\/cman1930\/network\/admin\/cman.ora\r\nInstance Log directory    \/u01\/app\/oracle\/diag\/netcman\/ocf-cman-1\/cman-test\/alert\r\nInstance Trace directory  \/u01\/app\/oracle\/diag\/netcman\/ocf-cman-1\/cman-test\/trace\r\nThe command completed successfully.\r\n<\/pre>\n<p>Stop should work as well:<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true \">$ \/u01\/app\/oracle\/scripts\/cman_service.sh -o \/u01\/app\/oracle\/product\/cman1930 -c cman-test -a stop\r\nVERSION         = 19.3.0.0.0\r\nORACLE_HOME     = \/u01\/app\/oracle\/product\/cman1930\r\nVERSION         = 19.3.0.0.0\r\nORACLE_HOME     = \/u01\/app\/oracle\/product\/cman1930\r\n\r\nCMCTL for Linux: Version 19.0.0.0.0 - Production on 12-JUL-2019 09:28:34\r\n\r\nCopyright (c) 1996, 2019, Oracle.  All rights reserved.\r\n\r\nCurrent instance cman-test is already started\r\nConnecting to (DESCRIPTION=(address=(protocol=tcp)(host=ocf-cman-1)(port=1521)))\r\nThe command completed successfully.\r\n<\/pre>\n<p><strong>Add the service in systemctl<\/strong><\/p>\n<pre class=\"lang:sh decode:true\"># as root:\r\n\r\ncat &lt;&lt;EOF &gt; \/etc\/systemd\/system\/cman-test.service\r\n[Unit]\r\nDescription=CMAN Service for cman-test\r\nDocumentation=https:\/\/www.ludovicocaldara.net\/dba\/cman-oci-install\r\nAfter=network-online.target\r\n\r\n[Service]\r\nUser=oracle\r\nGroup=oinstall\r\nLimitNOFILE=10240\r\nMemoryLimit=8G\r\nRestartSec=30s\r\nStartLimitInterval=1800s\r\nStartLimitBurst=20\r\nExecStart=\/u01\/app\/oracle\/scripts\/cman_service.sh -c cman-test -a start -o \/u01\/app\/oracle\/product\/cman1930\r\nExecReload=\/u01\/app\/oracle\/scripts\/cman_service.sh -c cman-test -a reload -o \/u01\/app\/oracle\/product\/cman1930\r\nExecStop=\/u01\/app\/oracle\/scripts\/cman_service.sh -c cman-test -a stop -o \/u01\/app\/oracle\/product\/cman1930\r\nKillMode=control-group\r\nRestart=on-failure\r\nType=forking\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\nAlias=service-cman-test.service\r\nEOF\r\n\r\n\/usr\/bin\/systemctl enable cman-test.service\r\n\r\n# start\r\n\/usr\/bin\/systemctl start cman-test\r\n# stop\r\n\/usr\/bin\/systemctl stop cman-test\r\n<\/pre>\n<p><strong>Open firewall ports<\/strong><\/p>\n<p>By default, new OL7 images use firewalld. Just open the port 1521 from the public zone:<\/p>\n<pre class=\"lang:plsql decode:true\"># as root:\r\nfirewall-cmd --permanent --add-port=1521\/tcp\r\nfirewall-cmd --reload\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Bonus: have a smart environment!<\/strong><\/p>\n<pre class=\"lang:plsql highlight:0 decode:true \"># as root:\r\nyum install -y git rlwrap\r\n\r\n# Connect as oracle\r\nsudo su - oracle\r\n\r\n# Clone this repository\r\ngit clone https:\/\/github.com\/ludovicocaldara\/COE.git\r\n\r\n# Enable the profile scripts\r\necho \". ~\/COE\/profile.sh\" &gt;&gt; $HOME\/.bash_profile\r\n\r\n# set the cman1930 home by default:\r\necho \"setoh cman1930\" &gt;&gt; $HOME\/.bash_profile\r\necho \"export TNS_ADMIN=\/u01\/app\/oracle\/network\/admin\" &gt;&gt; $HOME\/.bash_profile\r\n\r\n# Load the new profile\r\n. ~\/.bash_profile\r\n<\/pre>\n<pre class=\"lang:plsql decode:true \">[root@ocf-cman-1 tmp]# su - oracle\r\nLast login: Fri Jul 12 09:49:09 GMT 2019 on pts\/0\r\nVERSION         = 19.3.0.0.0\r\nORACLE_HOME     = \/u01\/app\/oracle\/product\/cman1930\r\n\r\n# [ oracle@ocf-cman-1:\/home\/oracle [09:49:54] [19.3.0.0.0 [CLIENT] SID=\"not set\"] 0 ] #\r\n# # ahhh, that;s satisfying<\/pre>\n<p>&#8212;<\/p>\n<p>Ludo<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Installing and configuring CMAN is a trivial activity, but having the steps in one place is better than reinventing the wheel. Prepare for the install Download the Oracle Client 19.3.0.0 in the Oracle Database 19c download page. Choose this one: &hellip; <a href=\"https:\/\/www.ludovicocaldara.net\/dba\/cman-oci-install\/\">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":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[321,326,309,3,315,330],"tags":[],"class_list":["post-1882","post","type-post","status-publish","format-standard","hentry","category-aced","category-oracle","category-oracle-cloud","category-oracledb","category-oracle-database-19c","category-oracle-inst-upg"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/1882","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=1882"}],"version-history":[{"count":4,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/1882\/revisions"}],"predecessor-version":[{"id":1887,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/1882\/revisions\/1887"}],"wp:attachment":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/media?parent=1882"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/categories?post=1882"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/tags?post=1882"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}