The Oracle Net Listener (listener) listens
on a network port (listening endpoints) for incoming database requests. A
listening endpoint defines the protocol addresses the listener is
defined to listen on. Listening endpoints include HTTP, FTP, WebDAV, and
Oracle XML. Look at the ORACLE XML DB Developer’s Guide for more detail on registering FTP, HTTP, and WebDAV listening points.
The process is fairly simple. The listener receives a
request and hands the request to a service handler, which is a server
process that runs on the same platform as the Oracle database server.
The service handler can be a dedicated server or a dispatcher, the
latter of which works with shared servers.
The PMON background process registers the service
information to the listener. During registration, PMON gives the
listener information on the database services and instance information.
PMON then tries to register with the listener once the listener has been
started. Dynamic registration is supported with the alter system
register command. If PMON has not registered with the listener, a TNS
listener error will occur. View the Oracle Database 11g Error Messages reference manual for more details.
The listener will receive the database request and
spawn a dedicated server process if the environment is configured for
the dedicated server architecture. The listener will hand the request
over to a dispatcher if running a shared server architecture. A client
application can bypass the listener if it is running on the same
platform as the database server. Once the listener hands off the request
it will resume listening for additional network requests.
A default listener (named listener) is configured at
installation with the Oracle Net Configuration Assistant making it easy
to start up the default listener when a system is first built. An
additional ICP protocol address is defined for external routes (EXTPROC)
during installation.
The following is a sample listener.ora file:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = eclipse)(PORT = 1521))
)
)
)
Table 1 illustrates the contents of the listener.ora file.
Table 1. Listener.ora File Formats
Parameter | Description |
---|
DESCRIPTION | This defines a connect descriptor for a net service name. |
DESCRIPTION_LIST | This defines a list of connect descriptors. |
LISTENER | This defines the listener alias. |
ADDRESS | This defines the listener protocol address. |
ADDRESS_LIST | This defines a list of protocol addresses that contain common behavior. |
In the following, host defines the server name, PORT
defines the port number, SERVER defines the host server name, PIPE
defines the pipe name, and KEY defines a unique name for the service. It
is recommended that you use the Oracle SID value for the key.
Table 2 defines the components of the protocol definition.
Table 2. Protocol Examples in the listener.ora File
Protocol | Example |
---|
TCP | (PROTOCOL=tcp)(host=eclipse)(PORT=1521) |
TCP/IP with SSL | (PROTOCOL=tcps)(host=eclipse)(PORT=2484) |
IPC | (PROTOCOL=ipc)(KEY=cust) |
Named pipes | (PROTOCOL=nmp)(SERVER=eclipse)(PIPE=pipe01) |
SDP | (PROTOCOL=sdp)(host=eclipse)(PORT=1521) |
After
installation, the Oracle Net Manager can be used to modify the listener
configuration. Some of the values that can be configured for the
listener include the following:
If the default port of 1521 is not specified,
the LOCAL_LISTENER initialization parameter needs to be defined through
a naming method. The LOCAL_LISTENER parameter is dynamic and can be set
with the alter system command.
Be
careful, because the LISTENER parameter overrides the LOCAL_LISTENER
parameter. A host system can have multiple IP addresses, and a listener
can be configured to listen on them.
The I/O buffer size for send and receive operations can be defined.
Heterogeneous services can be set to support additional services such as external routines.
The
QUEUESIZE parameter can be defined for environments that may have a
large number of concurrent connection requests for a listener on a
listening endpoint.
Password Authentication
In Oracle 11g, the
listener administration is secure through the operating system
authentication. So the administration is then restricted to the account
that started the listener. Another option is to set a password for the
listener. Also for remote administration of the listener a password is
required. The change_password command can be used to change a password
or set a new password. If a password is not set, someone can
accidentally impact the availability of the database—for example,
accidentally shutting down the listener. If you don’t have a listener,
new sessions cannot be established. It is important that a DBA protect
access to listener management.
Using the listener utility, lsnrctl, listener configurations can be managed. The following example sets the listener password:
> lsnrctl
lsnrctl> change_password
Old password: <enter>
New password: newpassword
Reenter new password: newpassword
lsnrctl> save_config
Multiple Listeners
Multiple listeners can be defined for a service and
can offer a number of advantages for more complex environments. These
advantages include the following:
(DESCRIPTION =
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=eclipse)(PORT=1521))
(CONNECT_DATA=
(SERVICE_NAME=customer.us.beginner.com)))
Connection Pooling
A shared server architecture is used to
improve user scalability. So, it is assumed that if this architecture is
being used, there is a potential for a large number of users. As
mentioned previously, at any point in time there can be a large
percentage of idle processes. Connection pooling allows the database
server to time out sessions that are idle and then use the connection to
support an active session. These sessions remain open but in an idle
state. When they become active again, a connection is reestablished.