MANAGING ORACLE LISTENER
Characteristics of the Listener Process
The listener is a process running on a node that listens for incoming connections on behalf of a database or a number of databases. The following are the characteristics of a listener:
• A listener process can listen for more than one database
• Multiple listeners can listen on behalf of a single database to perform load balancing
• The listener can listen for multiple protocols
• The default name of the listener in Oracle Net is LISTENER
• The name of the listener must be unique per listener.ora file
Note: Oracle9i databases requires a release 9.0 listener. Previous versions of the listener are not supported. However, it is possible to use a release 9.0 listener with previous versions of the Oracle database.
The Listener Responses
When a connection request is made by a client to a server, the listener performs one of the following:
• Spawns a server process and passes the connection to it
• Hands off the connection to a dispatcher or server process in an Oracle Shared Server configuration
• Redirects the connection to a dispatcher or server process
Configuring the Listener
The listener can be configured in two ways:
Static Service Registration
In order for a listener to accept client requests from an Oracle8 or earlier release, the
listener.ora file must be configured. The static configuration is also required for Oracle
Enterprise Manager (OEM) and other services such as external procedures and Heterogeneous Services.
Dynamic Service Registration
An Oracle9i instance uses service registration to inform the listener about its database services. Service registration relies on the PMON process to register instance information with the listener. PMON also informs the listener about the current state and load of the instance and Shared Server dispatchers.
If Oracl9i JVM is installed, HTTP and IIOP listening endpoints can be registered dynamically with the listener.
Benefits of Dynamic Service Registration
• The listener.ora file does not require the SID_LIST_LISTENER_NAME parameter that specifies information on the databases served by the listener. This parameter is still required if the management tool you are using requires it.
• Connect-time failover is enabled.
• Connection load balancing is enabled for shared servers.
listener.ora File Contents
1. LISTENER =
2. (ADDRESS_LIST =
3. (ADDRESS= (PROTOCOL= TCP)(Host= stc1)(Port= 1521))
)
4. SID_LIST_LISTENER =
5. (SID_LIST =
6. (SID_DESC =
7. (ORACLE_HOME= /home/oracle)
8. (GLOBAL_DBNAME = ORCL.us.oracle.com)
9. (SID_NAME = ORCL)
)
10. ...sample additional SID description ...
)
The default listener.ora file contains the following parameters:
1. The name of the listener. The default name is LISTENER.
2. The ADDRESS_LIST parameter contains a block of addresses at which the listener
listens for incoming connections. Each of the addresses defined in this block represents
a different way by which a listener receives a connection.
3. The TCP address identifies incoming TCP connections from clients on the network
attempting to connect to port 1521. The clients use the port defined in their
tnsnames.ora file to connect to this listener. Based on the SID_LIST defined for this
listener, the listener specifies the database to which to connect. Please note that is
possible to configure multiple listeners here as long as they have unique names and
unique ports on the node where they are configured. Each listener configured will have
its own SID_LIST but a single database can be serviced by multiple listeners.
4. A listener can listen for more than one database on a machine. The
SID_LIST_LISTENER_NAME block or parameter is where these SIDs are defined.
5. The SID_LIST parameter is defined if more than one SID is defined.
6. The SID_DESC parameter must exist for each defined SID.
7. The ORACLE_HOME is where the home directory of the database is defined. This
enables the listener to identify the location of a database executable file.
8. The parameter GLOBAL_DBNAME identifies the global database name of the database, a name comprised of the database name and database domain. The global database name is of the form database_name.database_domain. Consider, for example, orcl.us.acme.com where the database name portion, orcl, is a simple name you wish to call your database. The database domain portion, us.oracle.com, specifies the database domain in which the database is located, making the global database name unique You can obtain the GLOBAL_DBNAME value from the SERVICE_NAMES parameter in the initialization parameter file. This parameter must be embedded under SID_DESC and should match the value of the SERVICE_NAMES parameter.
9. The SID_NAME parameter defines the name of the SID on behalf of which the listener accepts connections.
10. By default, an example SID is defined here.
LISTENER.ORA Parameters
Parameter Description
CONNECT_TIMEOUT_listener_name Sets the number of seconds that the listener waits for the server process to get a valid database query after the session has started.
LISTENER_address Defines the listening addresses for the listener.
LOG_DIRECTORY_listener_name Controls the directory in which the log file
is written.
LOG_FILE_listener_name Specifies the filename to which the log information is written.
LOGGING_listener_name By default, logging is always on unless you provide this parameter and turn logging off.
PASSWORDS_listener_name Sets a nonencrypted password for authentication to the Listener Control utility (LSNRCTL).
SAVE_CONFIG_ON_STOP_listener_name Any changes made by the LSNRCTL SET command are made permanent if the if the parameter is set to TRUE.
SERVICE_LIST_listener_name Defines the service served by the listener. This is the same as the SID_LIST, made more generic for nondatabase servers.
SID_LIST_listener_name Defines the SID of the databases served by the listener.
STARTUP_WAIT_TIME_listener_name Sets the number of seconds that the listener sleeps before responding to the first LSNRCTL STATUS command. This assures that a listener with a slow protocol has time to start up before responding to a
status request.
TRACE_DIRECTORY_listener_name Controls the directory in which the trace
file is written.
TRACE_FILE_listener_name Sets the name of the trace file.
TRACE_LEVEL_listener_name Turns tracing off or to a specified level.
Creating an Additional Listener
By default a listener called LISTENER is created after the installation. If you need to create an additional listener, the following steps describe the procedure:
1. Start up Oracle Net Manager
2. Click the Listeners icon.
3. Select Create from the Edit menu.
4. Enter a listener name in the Listener Name field on the dialog box that appears.
5. Select Listening Locations from the drop-down list within Oracle Net Manager for your listener.
6. Click the Add Address button.
7. Change or enter information in the Protocol, the Host, and Port fields as necessary.
8. Select Save Network Configuration from the File menu of Oracle Met Manager.
Configuring Database Services
1. Select Database Services from the drop-down list within Oracle Net for your listener.
2. Click the Add Database button.
3. Enter the global database name, the Oracle home directory, and the SID in the
appropriate fields.
4. Select Save Network Configuration from the File menu of Net Manager.
Configuring Listener Logging and Tracing
1. Select General Parameters from the pull-down menu within Net Manager for your
listener.
2. Click the Logging & Tracing tab.
3. Enable logging by selecting the Logging Enabled option button.
4. Enter the path and filename for a log file.
5. Select Save Network Configuration from the File menu of Oracle Net.
6. Repeat above steps for tracing (if needed). Be aware that logging and especially tracing
can use large amounts of disk space and should be monitored. Tracing should only be
used if needed.
Configuring Service Registration
The following init.ora parameters must be configured for service registration to work:
• SERVICE_NAMES for the database service name
• INSTANCE_NAME for the instance name
Examples:
SERVICE_NAMES=sales.us.oracle.com
INSTANCE_NAME=salesdb
How to configure PMON for Dynamic Service Registration:
• By default, PMON registers with a local listener on the server with the following settings:
– Listener name LISTENER
– Port 1521
– Protocols TCP/IP
– SID name Default instance
– Host name Default host name
Using a Non-default Listener
You can force PMON to register with a local listener on the server that does not use TCP/IP or use port 1521 by configuring the LOCAL_LISTENER parameter in the init.ora file as follows:
LOCAL_LISTENER=listener_alias
listener_alias must be resolved to the listener protocol address through a naming
method such as tnsnames.ora.
An example entry in the tnsnames.ora follows:
listener_name=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1421)))
Listener Control Utility (LSNRCTL)
Commands from the Listener Control utility can be
issued from the command-line or from the LSNRCTL
prompt.
•
$ lsnrctl <command name>
LSNRCTL> <command name>
Control a non-default listener
LSNRCTL> set current_listener listener02
When the lsnrctl command is issued, the command will work against the default listener “listener” unless the SET LISTENER command is executed. Another way to control different listeners is to use the listener name as a command modifier:
$ lsnrctl start listener02
Starting the Listener
LSNRCTL> START [listener_name]
or
$ lsnrctl start [listener_name]
Stopping the Listener
LSNRCTL> STOP [listener_name]
or
$ lsnrctl stop [listener_name]
Command Description
CHANGE_PASSWORD Dynamically changes the encrypted password of a listener.
EXIT Quits the LSNRCTL utility.
HELP Provides the list of all available LSNRCTL commands.
QUIT Provides the functionality of the EXIT command.
RELOAD Shuts down everything except listener addresses and rereads the listener.ora file. You use this command to add or change services without actually stopping the listener.
SAVE_CONFIG Creates a backup of your listener configuration file (called listener.bak) and updates the listener.ora file itself to reflect any changes
SERVICES Provides detailed information about the services the listener listens for.
SET parameter This command sets a listener parameter.
SHOW parameter This command lists the value of a listener parameter.
LSNRCTL SET and SHOW Modifiers
The SET modifier is used to change listener parameters in the Listener Control utility environment.
The SHOW modifier is used to display the values of the parameters set for the listener.
LSNRCTL> SET trc_level ADMIN
LSNRCTL> SHOW connect_timeout
Tuning Oracle Listener
The Listener is a process residing on a database server or other machine that "listens" for database connection requests. When a request is received the Listener hands off or passes on the connection to a database server process. Following is a very simple Listener configuration file. This file is called listener.ora by default and is placed in the $ORACLE_HOME/network/admin directory.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = <hostname>)
(PORT = 1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = <SID>.<xyz.com>)
(SID_NAME = <SID>)
(ORACLE_HOME = /oracle/ora92)
)
)
What can be done to tune or at least improve the Listener under certain circumstances?
Listener Queue Size. Allows a larger number of Listener requests to be serviced by allowing them to wait in a queue.
Listener Logging and Tracing. Logging is defaulted on and tracing is defaulted off.
Multiple Listeners and Load Balancing. Randomized load balancing can be created between multiple Listeners, pointing at the same database.
16.1.1 Listener Queue Size
Very large quantities of network requests and traffic to the Listener can cause the Listener to use a queue in order to allow the Listener to keep up with requests. If there are too many requests then waiting requests to the Listener will be queued. The default length of the Listener queue is operating-system-specific and can be increased by setting the QUEUESIZE parameter in the Listener configuration file.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = <hostname>)
(PORT = 1521)
(QUEUESIZE = 50)
)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = <SID>.<xyz.com>)
(SID_NAME = <SID>)
(ORACLE_HOME = /oracle/ora92)
)
)
16.1.2 Switching Off Listener Logging and Tracing
By default a file called $ORACLE_HOME/network/log/listener.log file is created and constantly appended to. Tracing can also be switched on but is off by default. Logging and tracing of the Listener process can be switched off by setting the appropriate configuration parameters in the listener.ora file. Switch off Listener logging and especially tracing if this is switched on. Log and trace files can become extremely large and will affect performance. Unless really necessary do not log or trace the Listener process.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = <hostname>)
(PORT = 1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = <SID>.<xyz.com>)
(SID_NAME = <SID>)
(ORACLE_HOME = /oracle/ora92)
)
)
LOGGING_LISTENER = OFF
TRACE_LEVEL_LISTENER = OFF
16.1.3 Multiple Listeners and Load Balancing
Load balancing can help performance by providing multiple Listener connection points to a database server. If one Listener is busy another Listener process can be deferred to, thus reducing load on the first Listener. So let's add a Listener. The listener.ora configuration might now look something like that shown below. Note that the Listener called LISTENER2 uses a different port number to the Listener called LISTENER. Both of the two Listeners LISTENER and LISTENER2 allow connections to the same database.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = <hostname>)
(PORT = 1521))
)
)
LISTENER2 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = <hostname>)
(PORT = 1522))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = <SID>.<xyz.com>)
(SID_NAME = <SID>)
(ORACLE_HOME = /oracle/ora92)
)
)
SID_LIST_LISTENER2 =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = <SID>.<xyz.com>)
(SID_NAME = <SID>)
(ORACLE_HOME = /oracle/ora92)
)
How do we implement load balancing between multiple Listener processes?
The configuration file shown opposite is the client configuration file called the Transparent Network Substrate configuration file. This file is placed in the $ORACLE_HOME/network/ admin directory and is called tnsnames.ora. The tnsnames.ora file, which is a local naming client connection configuration file, can be placed on both Oracle server and client installations, specifying how a client process such as SQL*Plus can communicate with a Listener process. Note how there are two connection strings with ports 1521 and 1522, matching the different Listener address in the previously shown listener.ora file.
<TNSname> =
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = YES)
(ADDRESS = (PROTOCOL = TCP) (HOST = <hostname>)
(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP) (HOST = <hostname>)
(PORT = 1522))
)
(CONNECT_DATA = (SID = <SID>) (ORACLE_HOME =
/oracle/ora81))
)