{"id":371,"date":"2018-05-18T02:23:17","date_gmt":"2018-05-18T02:23:17","guid":{"rendered":"https:\/\/www.spotonoracle.com\/?p=371"},"modified":"2018-05-18T02:41:59","modified_gmt":"2018-05-18T02:41:59","slug":"little-trick-with-lsnrctl","status":"publish","type":"post","link":"https:\/\/www.spotonoracle.com\/?p=371","title":{"rendered":"Little trick with lsnrctl"},"content":{"rendered":"<p>Are you running RAC\/GI with role separation? You&#8217;re tired of constantly switching between &#8220;oracle&#8221; and &#8220;grid&#8221; users or you don&#8217;t have access to &#8220;grid&#8221; at all?<br \/>\nThis little trick saves me lots of time whenever I need to check the status or services details of a listener running as &#8220;grid&#8221;. I hope it serves you as well as it does serve me \ud83d\ude42<\/p>\n<p>This gives me the listener names running on the connected node:<\/p>\n<pre class=\"brush: bash; collapse: false; title: ; wrap-lines: false; notranslate\" title=\"\">\r\n$ ps -ef|grep tnslsnr\r\ngrid      3468     1  0 21:50 ?        00:00:00 \/u01\/app\/gi12201\/bin\/tnslsnr ASMNET1LSNR_ASM -no_crs_notify -inherit\r\ngrid      3643     1  0 21:50 ?        00:00:00 \/u01\/app\/gi12201\/bin\/tnslsnr LISTENER -no_crs_notify -inherit\r\ngrid      3646     1  0 21:50 ?        00:00:00 \/u01\/app\/gi12201\/bin\/tnslsnr MGMTLSNR -no_crs_notify -inherit\r\ngrid      3652     1  0 21:50 ?        00:00:00 \/u01\/app\/gi12201\/bin\/tnslsnr LISTENER_SCAN3 -no_crs_notify -inherit\r\ngrid      3665     1  0 21:50 ?        00:00:00 \/u01\/app\/gi12201\/bin\/tnslsnr LISTENER_SCAN2 -no_crs_notify -inherit\r\n<\/pre>\n<p>By default, every listener in a GI\/RAC setup has an IPC end-point with the KEY being the same as the listener name. For instance:<\/p>\n<pre class=\"brush: plain; collapse: false; highlight: [2]; title: ; wrap-lines: false; notranslate\" title=\"\">\r\nListening Endpoints Summary...\r\n  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN1)))\r\n  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=192.168.56.55)(PORT=1523)))\r\n  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.55)(PORT=1521)))\r\n<\/pre>\n<p>So you can simply run lsnrctl with the connect descriptor on the command line (as oracle):<\/p>\n<pre class=\"brush: bash; collapse: false; highlight: [1]; title: ; wrap-lines: false; notranslate\" title=\"\">\r\n$ lsnrctl status &quot;(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN1)))&quot;\r\n\r\nLSNRCTL for Linux: Version 12.2.0.1.0 - Production on 17-MAY-2018 22:12:49\r\n\r\nCopyright (c) 1991, 2016, Oracle.  All rights reserved.\r\n\r\nConnecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN1)))\r\nSTATUS of the LISTENER\r\n------------------------\r\nAlias                     LISTENER_SCAN1\r\nVersion                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production\r\nStart Date                17-MAY-2018 21:52:41\r\nUptime                    0 days 0 hr. 20 min. 8 sec\r\nTrace Level               off\r\nSecurity                  ON: Local OS Authentication\r\nSNMP                      OFF\r\nListener Parameter File   \/u01\/app\/gi12201\/network\/admin\/listener.ora\r\nListener Log File         \/u01\/app\/grid\/diag\/tnslsnr\/ol7122rac2\/listener_scan1\/alert\/log.xml\r\nListening Endpoints Summary...\r\n  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN1)))\r\n  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=192.168.56.55)(PORT=1523)))\r\n  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.55)(PORT=1521)))\r\nServices Summary...\r\nService &quot;65388e79ee096b69e0533238a8c08c32.localdomain&quot; has 2 instance(s).\r\n  Instance &quot;RAC11&quot;, status READY, has 2 handler(s) for this service...\r\n  Instance &quot;RAC12&quot;, status READY, has 2 handler(s) for this service...\r\nService &quot;RAC1.localdomain&quot; has 2 instance(s).\r\n  Instance &quot;RAC11&quot;, status READY, has 2 handler(s) for this service...\r\n  Instance &quot;RAC12&quot;, status READY, has 2 handler(s) for this service...\r\nService &quot;pdbrac1.localdomain&quot; has 2 instance(s).\r\n  Instance &quot;RAC11&quot;, status READY, has 2 handler(s) for this service...\r\n  Instance &quot;RAC12&quot;, status READY, has 2 handler(s) for this service...\r\nThe command completed successfully\r\n<\/pre>\n<p>Yes, this only works for listeners that run on the node you&#8217;re connected to. You can&#8217;t do it across nodes, but I still find it extremely useful.<\/p>\n<p>For your convenience, you can put the connect descriptors in the TNSNAMES.ORA sourced by &#8220;oracle&#8221;:<\/p>\n<pre class=\"brush: bash; collapse: false; highlight: [2,4]; title: ; wrap-lines: false; notranslate\" title=\"\">\r\n$ cat $TNS_ADMIN\/tnsnames.ora \r\nlistener_scan1=(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN1)))\r\n\r\n$ lsnrctl services listener_scan1\r\n\r\nLSNRCTL for Linux: Version 12.2.0.1.0 - Production on 17-MAY-2018 22:30:10\r\n\r\nCopyright (c) 1991, 2016, Oracle.  All rights reserved.\r\n\r\nConnecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN1)))\r\nServices Summary...\r\nService &quot;65388e79ee096b69e0533238a8c08c32.localdomain&quot; has 2 instance(s).\r\n  Instance &quot;RAC11&quot;, status READY, has 2 handler(s) for this service...\r\n    Handler(s):\r\n      &quot;DEDICATED&quot; established:0 refused:0 state:ready\r\n         REMOTE SERVER\r\n         (ADDRESS=(PROTOCOL=TCPS)(HOST=192.168.56.53)(PORT=1523))\r\n...\r\n<\/pre>\n<p>It also works within the lsnrctl command line:<\/p>\n<pre class=\"brush: bash; collapse: false; highlight: [1,9,11]; title: ; wrap-lines: false; notranslate\" title=\"\">\r\n$ lsnrctl\r\n\r\nLSNRCTL for Linux: Version 12.2.0.1.0 - Production on 17-MAY-2018 22:39:58\r\n\r\nCopyright (c) 1991, 2016, Oracle.  All rights reserved.\r\n\r\nWelcome to LSNRCTL, type &quot;help&quot; for information.\r\n\r\nLSNRCTL&gt; set current_listener (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN1)))\r\nCurrent Listener is (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN1)))\r\nLSNRCTL&gt; services\r\nConnecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN1)))\r\nServices Summary...\r\nService &quot;65388e79ee096b69e0533238a8c08c32.localdomain&quot; has 2 instance(s).\r\n  Instance &quot;RAC11&quot;, status READY, has 2 handler(s) for this service...\r\n    Handler(s):\r\n      &quot;DEDICATED&quot; established:0 refused:0 state:ready\r\n         REMOTE SERVER\r\n         (ADDRESS=(PROTOCOL=TCPS)(HOST=192.168.56.53)(PORT=1523))\r\n      &quot;DEDICATED&quot; established:0 refused:0 state:ready\r\n         REMOTE SERVER\r\n         (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.53)(PORT=1521))\r\n...\r\n<\/pre>\n<p>Any comments? I&#8217;m listening&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you running RAC\/GI with role separation? You&#8217;re tired of constantly switching between &#8220;oracle&#8221; and &#8220;grid&#8221; users or you don&#8217;t have access to &#8220;grid&#8221; at all? This little trick saves me lots of time whenever I need to check the status or services details of a listener running as &#8220;grid&#8221;. I hope it serves you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-371","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/posts\/371","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=371"}],"version-history":[{"count":3,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/posts\/371\/revisions"}],"predecessor-version":[{"id":374,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=\/wp\/v2\/posts\/371\/revisions\/374"}],"wp:attachment":[{"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=371"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=371"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.spotonoracle.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=371"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}