2081 11

BIT352 ยท 2081 ยท 5 marks

What is listener? Explain about listener.ora and tnsnames.ora file in oracle database.

What is listener? Explain about listener.ora and tnsnames.ora file in oracle database. [5]

Database AdministrationChapter 10: Advanced Database Features and ToolsListener definition and purpose

Quick answer

A listener is a server-side network process in Oracle Database that listens for incoming client connection requests on a specific network protocol (usually TCP/IP) and a specific port (default port: 1521).

Listener, listener.ora, and tnsnames.ora in Oracle Database


Listener

When a client wants to connect to an Oracle database, it sends a connection request to the listener. The listener receives the request, verifies it, and then hands off (redirects) the connection to the appropriate Oracle database instance.

Key points about Listener:

  • It runs on the database server machine.
  • It is managed using the lsnrctl (Listener Control) utility.
  • Common commands: lsnrctl start, lsnrctl stop, lsnrctl status
  • Without a running listener, remote clients cannot connect to the Oracle database.

listener.ora File

The listener.ora file is a server-side configuration file that defines the listener's properties and settings.

Location: $ORACLE_HOME/network/admin/listener.ora

It contains:

  • The name of the listener (default: LISTENER)
  • The protocol, host, and port on which the listener listens
  • The Oracle database services/SIDs it serves

Example:

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS =
        (PROTOCOL = TCP)
        (HOST = myserver.example.com)
        (PORT = 1521)
      )
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = ORCL)
      (ORACLE_HOME = /u01/app/oracle/product/19c/dbhome_1)
    )
  )

Key parameters:

ParameterDescription
PROTOCOLNetwork protocol (TCP/IP)
HOSTServer hostname or IP address
PORTPort number (default 1521)
SID_NAMEOracle System Identifier

tnsnames.ora File

The tnsnames.ora file is a client-side configuration file that maps logical service names (aliases) to Oracle database connection descriptors (host, port, service name).

Location: $ORACLE_HOME/network/admin/tnsnames.ora

When a client application uses a connect string like sqlplus user/pass@ORCL, Oracle looks up ORCL in tnsnames.ora to find the actual connection details.

Example:

ORCL =
  (DESCRIPTION =
    (ADDRESS =
      (PROTOCOL = TCP)
      (HOST = myserver.example.com)
      (PORT = 1521)
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.example.com)
    )
  )

Key parameters:

ParameterDescription
ORCLNet service name (alias used by client)
HOSTIP address or hostname of the database server
PORTPort number of the listener
SERVICE_NAMEThe Oracle database service name
SERVERConnection type (DEDICATED or SHARED)

Difference Between listener.ora and tnsnames.ora

Featurelistener.oratnsnames.ora
LocationServer sideClient side
PurposeConfigures the listener processMaps alias to connection details
Used byOracle ListenerClient applications
Managed byDBA (server)DBA / end user (client)

In summary: The listener acts as a gatekeeper on the server; listener.ora tells the listener how to operate; and tnsnames.ora tells the client where and how to connect to the database.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.