About
When an database instance starts, it registers itself with a listener using one or more service names. When a client program or database connects to a listener, it requests a connection to a service.
A service name can identify multiple database instances, and an instance can belong to multiple services.
For this reason, the listener acts as a mediator between the client and instances and routes the connection request to the appropriate instance. Clients connecting to a service need not specify which instance they require.
To connect to a database service, clients first contact a listener process that typically resides on the database server. The listener receives incoming client connection requests and sends these requests to the database server. After the connection is established, the client and database server communicate directly.
The listener knows which services can handle connection requests because an Oracle database dynamically registers this information with the listener. This process of registration is called service registration. Registration also provides the listener with information about the database instances and the service handlers available for each instance.
Articles Related
Listener in an connection request
When the listener receives the client request, it selects one of the registered service handlers. Depending on the type of handler selected, the communication protocol used, and the operating system of the database server, the listener performs one of the following actions:
- Hands the connect request directly off to a disptacher.
- Sends a redirect message back to the client with the location of the dispatcher or dedicated server process. The client then connects directly to the dispatcher or dedicated server process.
- Spawns a dedicated server process and passes the client connection to the dedicated server process.
After the listener has completed the connection operation for the client, the client communicates directly with the Oracle database without the listener's involvement. The listener resumes listening for incoming network sessions.
The process in the 3 steps:
- 1. The client sends a connection request to the listener.
- 2. The listener parses the client request and forwards it to the service handler for the database service requested.
- 3. The client connects to the database.
Listener Management
Configuration
A listener is configured with one or more listening protocol addresses, information about supported services, and parameters that control its run-time behavior. The listener configuration is stored in a configuration file named listener.ora.
To know more about the listener configuration, see this article: Oracle Database - Configuration of the Listener (listener.ora)
Restart
- Windows: Restart the listener service. Example : “OracleOraDb10g_home1TNSListener”
- linux:
cd $ORACLE_HOME/bin
./lsnrclt stop
./lsnrclt start
Useful Command
lsnrctl status
lsnrctl service
Tracing and Logging
To set tracing parameters with Oracle Enterprise Manager and Oracle Net Manager:
Oracle Net Manager
- Start Oracle Net Manager.
- In the navigator pane, expand Local > Profile.
- From the list in the right pane, select General.
- Click the Tracing tab.
- Specify the settings (see help for the setting)
- Choose File > Save Network Configuration.
This action add this line in the sqlnet.ora by example for the level admin : TRACE_LEVEL_SERVER = ADMIN
sqlnet.trc (for the client)
svr_pid.trc (for the server)
The default directory is ORACLE_HOME\network\trace.
Oracle Enterprise Manager
- Access the Oracle Net Administration page in Oracle Enterprise Manager.
- Select Listeners from the Administer list, and then select the Oracle home that contains the location of the configuration files.
- Click Go. The Listeners page appears.
- Select a listener, and then click Edit. The Edit Listeners page appears.
- Click the Logging & Tracing tab.
- Specify the settings.
- Click OK.
listener.trc
Support
Log Directory
- ORACLE_HOME\network\trace
- ORACLE_HOME\network\log