Re: Finding TNS listener ports

  • From: "Radoulov, Dimitre" <cichomitiko@xxxxxxxxx>
  • To: oracle-l@xxxxxxxxxxxxx
  • Date: Wed, 29 Jul 2020 22:34:57 +0200

On Solaris I would use something like this:

pgrep -lf '[t]nslsnr' |
  while read p x l x; do
    printf 'listener %s is listening on the following interfaces/ports:\n' "$l"
    pfiles "$p" |
       nawk '/sockname: AF_INET / && !/0.0.0.0/ {
           _[$3] = $5
         } END {
         for (__ in _) print __, _[__]
         }'
  done


Regards
Dimitre

On 29/07/2020 22.11, dimensional.dba@xxxxxxxxxxx wrote:


netstat -tulpn | grep LISTEN | grep tnslsnr | awk '{print $4" - "$7}'

192.168.10.24:12632 - 43885/tnslsnr

192.168.10.101:37980 - 43885/tnslsnr

192.168.10.101:47550 - 43880/tnslsnr

192.168.10.24:13254 - 43882/tnslsnr

192.168.10.23:61803 - 43882/tnslsnr

192.168.10.23:24813 - 43885/tnslsnr

192.168.10.24:34094 - 43880/tnslsnr

10.81.54.124:1521 - 43885/tnslsnr

10.81.54.123:1521 - 43880/tnslsnr

10.80.54.51:1521 - 43880/tnslsnr

192.168.10.101:1522 - 43882/tnslsnr

192.168.10.101:27891 - 43882/tnslsnr

192.168.10.23:1526 - 44007/tnslsnr

192.168.10.101:1526 - 44007/tnslsnr

192.168.10.24:1526 - 44007/tnslsnr

192.168.10.23:46646 - 43880/tnslsnr

192.168.10.23:1527 - 44010/tnslsnr

192.168.10.101:1527 - 44010/tnslsnr

192.168.10.24:1527 - 44010/tnslsnr

will show the ports the listeners are listening on and their pids

Then

~]$  ps -ef | grep tns | awk '{print $2" - "$8" - "$9}'

318 - [netns] -

43880 - /u01/app/19.0.0.0/grid/bin/tnslsnr - LISTENER

43882 - /u01/app/19.0.0.0/grid/bin/tnslsnr - LISTENER_IB

43885 - /u01/app/19.0.0.0/grid/bin/tnslsnr - LISTENER_SCAN1

44007 - /u01/app/19.0.0.0/grid/bin/tnslsnr - ASMNET1LSNR_ASM

44010 - /u01/app/19.0.0.0/grid/bin/tnslsnr - ASMNET2LSNR_ASM

Shows nice listener name the Oracle Home it is coming from and the pid number of the process

You just need to do a little more work with a script if you wanted to come up with something really nice like

NAME          PORT   PID ORACLE_HOME                                      NETWORK

LISTENER – 1521 – 43880 - /u01/app/19.0.0.0/grid/bin/tnslsnr - 10.80.54.51

*From:* oracle-l-bounce@xxxxxxxxxxxxx <oracle-l-bounce@xxxxxxxxxxxxx> *On Behalf Of *Courtney Llamas
*Sent:* Wednesday, July 29, 2020 12:32 PM
*To:* Bala <oratips@xxxxxxxxx>
*Cc:* oracle-l <oracle-l@xxxxxxxxxxxxx>
*Subject:* Re: Finding TNS listener ports

Try

netstat -a|grep LISTEN|grep EXTPROC

I don’t have multiple users, so grep oracle for me works but assuming yours will all be different user there.

Courtney Llamas | Strategic Customer Program | +1.713.374.2102

OracleManageability <https://www.oracle.com/manageability/>



    On Jul 29, 2020, at 2:28 PM, Bala <oratips@xxxxxxxxx
    <mailto:oratips@xxxxxxxxx>> wrote:

    Thanks much for email. Your solution would work if listener was
    listening for multiple databases. in our scenario,

    Each of the 25 plus databases use different unix user account and
    different port ( like 1530,1531........etc)

    thanks

    On Wed, Jul 29, 2020 at 3:00 PM Courtney Llamas
    <COURTNEY.LLAMAS@xxxxxxxxxx <mailto:COURTNEY.LLAMAS@xxxxxxxxxx>>
    wrote:

        How many listeners are running?   Typically, the multiple DBs
        can use the same listener.  So the 25 db’s may all be using
        default LISTNER.

        To see what listener processes are running:

        $ ps -ef|grep lsnr

         14700 12995  0 11:32 pts/2    00:00:00 grep lsnr

         16872     1  0 Jan07 ?        00:34:57
        /u01/app/oracle/product/19.0.0/dbhome_1/bin/tnslsnr LISTENER
        -inherit

        To see what the listener is doing…

        /u01/app/oracle/product/19.0.0/dbhome_1/bin/lsnrctl status
        LISTENER|grep PORT





        Or…

        /u01/app/oracle/product/19.0.0/dbhome_1/bin/lsnrctl status
        LISTENER|grep PORT



        Should give you an idea of how many listeners, and what ports
        are listening…







        Courtney Llamas | Strategic Customer Program | +1.713.374.2102

        OracleManageability <https://www.oracle.com/manageability/>



            On Jul 29, 2020, at 1:26 PM, Bala <oratips@xxxxxxxxx
            <mailto:oratips@xxxxxxxxx>> wrote:

            Gurus,

            We have over 25 Oracle 12cR2 databases with listeners
            running on one solaris server.

            Is there any quick way to find ports of running listeners
            in Solaris ?  ( some unix level command to execute and get
            listing of running listeners with ports ?)

            Thank you for your time.

            Best

--
            Bala Rao



--
    Bala Rao

Other related posts: