Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Ramana .

Asked: May 02, 2000 - 1:20 pm UTC

Last updated: April 25, 2006 - 11:51 pm UTC

Version:

Viewed 1000+ times

You Asked

How do I configure multiple listeners
for my database running on unix. The
requirement is something like, configure
two different listeners one on port 1521
and the other on port 1526, so that users
can connect by using either of ports.
Ultimately this is supposed to be used for
application segregation.

Thanks
Ramana Damarla
DBA

setenv TNS_ADMIN `pwd`
lsnrctl start
cd ..
!set
!ls


and Tom said...



Yes. you just need 1 install and >1 listener.ora file.

You would use the TNS_ADMIN environment variable to tell each listener where to get its configuration from. The TNS_ADMIN environment variable overrides the default directory for the network configuration files.

This is a common requirement for users who run "extprocs" (external procedures) in oracle8.0 and up for example. Since an extproc runs as the userid who started the listener, it is common to setup a listener that runs as the user 'nobody' or some other low priv'ed account to spawn the extprocs. A 'regular' listener listens for all other inbound requests.

Here is a 7.3.4 example I just did. I copied my listener.ora from network/admin to network/admin/another. I changed the PORT and the KEY in the second one. Then:


Thu Feb 10 19:32:18 EST 2000
(ora734@slackdog) /d01/home/ora734/network/admin/another

Thu Feb 10 19:32:18 EST 2000
(ora734@slackdog) /d01/home/ora734/network/admin/another

LSNRCTL for Solaris: Version 2.3.4.0.0 - Production on 10-FEB-00 19:32:43

Copyright (c) Oracle Corporation 1994. All rights reserved.

Starting /d01/home/ora734/bin/tnslsnr: please wait...

TNSLSNR for Solaris: Version 2.3.4.0.0 - Production
System parameter file is /d01/home/ora734/network/admin/another/listener.ora
Log messages written to /d01/home/ora734/network/log/listener.log
Listening on: (ADDRESS=(PROTOCOL=ipc)(DEV=10)(KEY=ora734))
Listening on: (ADDRESS=(PROTOCOL=tcp)(DEV=14)(HOST=138.2.5.206)(PORT=1566))

Connecting to (ADDRESS=(PROTOCOL=IPC)(KEY=ora734))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Solaris: Version 2.3.4.0.0 - Production
Start Date 10-FEB-00 19:32:46
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security OFF
SNMP OFF
Listener Parameter File /d01/home/ora734/network/admin/another/listener.ora
Listener Log File /d01/home/ora734/network/log/listener.log
Services Summary...
ora734 has 1 service handler(s)
The command completed successfully




So, that shows I have a listener on port 1566 and the key (listener name) is ora734. Now I cd and do it over:

Thu Feb 10 19:32:18 EST 2000
(ora734@slackdog) /d01/home/ora734/network/admin/another

Thu Feb 10 19:32:49 EST 2000
(ora734@slackdog) /d01/home/ora734/network/admin
setenv TNS_ADMIN `pwd`

Thu Feb 10 19:32:49 EST 2000
(ora734@slackdog) /d01/home/ora734/network/admin
lsnrctl start

LSNRCTL for Solaris: Version 2.3.4.0.0 - Production on 10-FEB-00 19:32:56

Copyright (c) Oracle Corporation 1994. All rights reserved.

Starting /d01/home/ora734/bin/tnslsnr: please wait...

TNSLSNR for Solaris: Version 2.3.4.0.0 - Production
System parameter file is /d01/home/ora734/network/admin/listener.ora
Log messages written to /d01/home/ora734/network/log/listener.log
Listening on: (ADDRESS=(PROTOCOL=ipc)(DEV=10)(KEY=ora734a))
Listening on: (ADDRESS=(PROTOCOL=tcp)(DEV=14)(HOST=138.2.5.206)(PORT=1525))

Connecting to (ADDRESS=(PROTOCOL=IPC)(KEY=ora734a))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Solaris: Version 2.3.4.0.0 - Production
Start Date 10-FEB-00 19:32:59
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security OFF
SNMP OFF
Listener Parameter File /d01/home/ora734/network/admin/listener.ora
Listener Log File /d01/home/ora734/network/log/listener.log
Services Summary...
ora734 has 1 service handler(s)
The command completed successfully



Now, i've got a second listener on port 1525 named ora734a.



Rating

  (8 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

question

atul, November 18, 2002 - 9:14 pm UTC

Sir,

How to set other listener as other user (nobody)..
and how to start it by logging it to other user??


Thanks.
atul

Tom Kyte
November 18, 2002 - 9:29 pm UTC

You log into the other user and you start it.

su - nobody -c <some script>

as root for example. You would create a script that sets up the proper environment (oracle_home, path, etc) and run lsnrctl start

Listening multiple ports on one listener

Ogun, June 11, 2003 - 2:32 am UTC

Hi Tom,

We are using MTS, and we want to configure a listener that listens two ports. Our aim is to configure one port to listen connections as dedicated, and the other port to listen connections as shared. What is the way to do this ?

Tom Kyte
June 11, 2003 - 7:02 am UTC

see the net admin guide for details on configuring a listener.ora file OR use the net assistant tool (gui) to do it.

Listener questions

Arun Gupta, March 03, 2004 - 2:21 pm UTC

Tom,
The listeners are giving me a hard time. I have following questions:
a) In 8i onwards, automatic service registration registers the database with default listener. Should the default listener have the name LISTENER and PORT 1521 or can any named listener (say LISTENER_XYZ) listening on port 1521 becomes the default listener?
b) I just installed a 10g database on a server which is already running 9i databases. The 10g database automatically registered with 9i listener. Whenever I try to connect to 10g database, I get an error that listener failed to spawn a dedicated server process. To get around this, I created a second 10g listener on port 1421. Is there a better way ?

Thanks

Tom Kyte
March 03, 2004 - 4:20 pm UTC

a) any listener, it is the "default port" that is connects to -- doesn't really care about the name.

b) you should use just the 10g listener for all, if you use the highest versioned listener, you can get away with a single listener for all databases. running more than one listener works fine however.

Can I rename the listener log file while the listener is up?

A reader, April 25, 2006 - 12:58 pm UTC

Hi Tom,

Can I rename the listener log file in Linux while the listener is up and accepting connections?
Will the rename of the file cause any problems?
Or should I shutdown the listener to do this?

Thanks for any help on this.

Tom Kyte
April 25, 2006 - 2:29 pm UTC

hmmm, it should be ok, a simple test would bear this out

a) rename it
b) if a new file appears with the old name - it is safe (meaning the listener opens the log file, seeks to the end, writes a message, closes it)
c) if a new file does not appear after it should - it is not safe

I have not tried that out - but it would be simple to test. If we write to it like the alert log, it would be safe.

Can I rename the listener log file while the listener is up?

A reader, April 25, 2006 - 2:51 pm UTC

Thanks for answering me Tom.
I have tried that (rename it and wait to see the new file as the alert log works) but it did not work so I changed it back.
I guess the only way to create the new file is to shutdown the listener and create the new file.

Thanks


Dave, April 25, 2006 - 2:57 pm UTC

there is another way

cp listner.log listener.log.old
cat /dev/null > listener.log

do what you will with old log

listeners on RAC,

A reader, April 25, 2006 - 3:22 pm UTC

Do we need to have listeners running on all the nodes of a RAC database?
How about agent if we are using grid control?

What is the difference between grid control and OEM?

Thanks,


Tom Kyte
April 25, 2006 - 11:51 pm UTC

You do not need to have listeners running on all nodes, in fact - you don't need a listener on any of them (the listener could be on yet another machine all together)

OEM is now called EM Grid Control in 10g. It is the next generation of OEM.

A reader, April 25, 2006 - 3:23 pm UTC

Thanks for tip Dave.

Have you tried your suggestion on a linux enviroment? Did you have any issues after doing the cp and the cat /dev/null?



More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library