oracledba.help
System

Listener

Overview

One of the most common tasks performed on a database is configuring the Oracle Network to allow users to connect to your database. The best tool for the job is none other than the Oracle Net Manager. With the Oracle Net Manager tool you can configure both the service that allows clients to connect to the database, known as the Listener, and the corresponding local client connections.

Create

The following steps cover the most common settings. Change them as required for your environment.

Run the Network Manager

 Windows
 Start → All Programs
    → Oracle OraDb1n_home 
    → Configuration and Migration Tools 
    → Net Manager
 For Windows it is actually easier to quickly create a vanilla Listener using the Net Configuration Assistant.

 LINUX\UNIX
 su - oracle
 cd $ORACLE_HOME/bin
 ./netmgr &

Configure Listener

 1. Expand Local → Select Listeners → Select +
    Listener Name: LISTENER

 2. Select Listening Locations then Add Address
    Address1
    Protocol: TCP/IP
    Host:     MyHostName
    Port:     1521

 3. Select Database ServicesAdd Database
    Database
    Global Database Name:   MyDatabaseName
    Oracle Home Directory:  <Use $ORACLE_HOME>
                            Ex: /u01/app/oracle/product/12.1.0.2/dbhome_1
    SID:                    MyInstanceName

 4. Select File menu then Save Network Configuration
    Start the listener with the new config.

 5. Start Listener
    OS> cd $ORACLE_HOME/network/admin
    OS> lsnrctl start LISTENER

On Windows this will create the corresponding Listener service.

The listener configuration file is created in $ORACLE_HOME/network/admin/listener.ora

Example listener.ora

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = DB1)
      (ORACLE_HOME = C:/app/oracle/product/11.2.0.3/db_1)
      (SID_NAME = DB1)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.42)(PORT = 1521))
    )
  )
  • Be careful if manually editing the listener.ora as erroneous characters (tabs, carriage returns etc.) can cause the listener to fail.

Stop/Start/Status

OS> lsnrctl stop
OS> lsnrctl start
OS> lsnrctl status

Advanced Listener Tasks

Creating an ACL (Access Control List)

1. Edit the file %ORACLE_HOME%\network\admin\sqlnet.ora.
   * Enable tcp.validnode_checking.
   * Set the tcp.invited_nodes.
     o If an IP address is not listed here it will be blocked.
     o All entries must be on one line.
     o Make sure to include entries for both localhost AND .
2. Bounce the listener.

   Example sqlnet.ora:
SQLNET.AUTHENTICATION_SERVICES = (NTS)
tcp.validnode_checking=yes
tcp.invited_nodes=(localhost,192.168.1.10,192.168.1.25,192,192.168.1.103)

The SQLNET.AUTHENTICATION_SERVICES entry as NTS is used on Windows database servers. It is listed here for completeness.

Delete Listener Log

OS> cd ORACLE_HOME\log\diag\tnslsnr\{DBNAME}\listener\alert
OS> lsnrctl set log_status off
OS> del log*.xml
OS> lsnrctl set log_status on

Logging

Immediate

 Turn on (default): lsnrctl set log_status on
 Turn off:          lsnrctl set log_status off

Permanent

 OS> lsnrctl
 LSNRCTL> set log_status off
 LSNRCTL> save_config

Sets the LOGGING command in the listener.ora file:

Example:

 LOGGING_LISTENER=OFF

Password Protecting

  1. Run lsnrctl with no options to invoke the listener console.
  2. Enter the change_password command and enter a new password when prompted. If it's the first time, just hit the enter key when prompted for the old password, since there isn't one yet.
  3. Enter the command save_config
 OS> lsnrctl

 LSNRCTL> change_password
 Old password:
 New password:
 Reenter new password:
 Connecting to ...
 Password changed for LISTENER

 LSNRCTL>save_config
 The command completed successfully

A PASSWORDS_LISTENER entry will be made in your listener.ora file.

<- System