How to Configure the Database Listener with Listener.ora in Oracle 12c

One important component of database processing is the listener process. The key file to the listener process in Oracle 12c is the listener.ora configuration file. This file identifies two things:

  • Each database it will listen for

  • On what ports (default 1521)

The file is located in ORACLE_HOME/network/admin.

A sample listener.ora file in Oracle 12c

# listener.ora Network Configuration File: /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/lis
tener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
 (SID_LIST =
  (SID_DESC =
   (GLOBAL_DBNAME = db01)
   (ORACLE_HOME = /u01/app/oracle/product/11.1.0/db_1)
   (SID_NAME = db01)
  )
  (SID_DESC =
   (GLOBAL_DBNAME = dev12c)
   (ORACLE_HOME = /u01/app/oracle/product/12.1.0/dbhome_1)
   (SID_NAME = dev12c)
  )
 )
LISTENER =
 (DESCRIPTION_LIST =
  (DESCRIPTION =
   (ADDRESS = (PROTOCOL = TCP)(HOST = orasvr01)(PORT = 1521))
  )
  (DESCRIPTION =
   (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
  )
 )

In the preceding code, you see two main sections: SID_LIST_LISTENER and LISTENER. The SID_LIST_LISTENER section identifies each database instance that the listener will service connections for. It lists the global database name, ORACLE_HOME, and SID.

As you need more databases, add the following section and customize the information:

  (SID_DESC =
   (GLOBAL_DBNAME = dev12c)
   (ORACLE_HOME = /u01/app/oracle/product/12.1.0/dbhome_1)
   (SID_NAME = dev12c)
  )

The LISTENER section identifies what host the database exists on and what port it accepts connections on:

  (DESCRIPTION =
   (ADDRESS = (PROTOCOL = TCP)(HOST = orasvr01)(PORT = 1521))
  )

Here you see the listener will listen on the HOST (server) orasvr01, and the port is 1521. Requests on other ports will not be acknowledged.

You can add more databases, even if they’re different database versions to the listener.ora. You can also add additional LISTENER processes (if you want to listen on multiple ports, for example).

You should be aware of one configuration option that isn’t recommend: Shared Servers. With this method, each user connection uses a shared process rather than a dedicated server process on the database server.

The sqlnet.ora file is one configuration file. It can be client or server side, usually located with the listener.ora or tnsnames.ora file. The sqlnet.ora file is a special options file where you can add parameters to the Oracle Net architecture. This file can exist both on servers to impact the listener process and on clients to influence TNS settings. For example, you can

  • Add commands to force increased tracing, logging options, or encryption.

  • Tell the listener to add a domain name to each database.

  • Direct the listener to look up connection information in an LDAP instead of a tnsnames.ora file.

Here is a sqlnet.ora file:

$ more sqlnet.ora
NAMES.DIRECTORY_PATH=TNSNAMES

The setting simply tells the client to use the tnsnames.ora file instead of any other resource (such as an LDAP).

How to start and stop the database listener in Oracle 12c

The database listener process reads the listener.ora and sqlnet.ora files for its configuration; the database administrator (DBA) manages it by using the lsnrctl command-line utility. You can use the utility to do these things to the listener:

  • Start

  • Stop

  • Check status

There is no direct relationship between the listener process and the database itself; the processes operate independently.

However, remember that the listener must be started before the database can service remote connections.

To start the listener, issue the lsnrctl start command:

[oracle@orasvr01 dbs]$ lsnrctl start
LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 19-MAY-2013 12:10:44
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Starting /u01/app/oracle/product/12.1.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 12.1.0.1.0 – Production
System parameter file is
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Log messages written to
/u01/app/oracle/diag/tnslsnr/orasvr01/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.66)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.66)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias           LISTENER
Version          TNSLSNR for Linux: Version 12.1.0.1.0 - Production
Start Date        19-MAY-2013 12:10:44
Uptime          0 days 0 hr. 0 min. 0 sec
Trace Level        off
Security         ON: Local OS Authentication
SNMP           OFF
Listener Parameter File
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Listener Log File
/u01/app/oracle/diag/tnslsnr/orasvr01/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.66)(PORT=1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=orasvr01)(PORT=5500))
(Security=(my_wallet_directory=/u01/app/oracle/admin/
dev12c/xdb_wallet))(Presentation=HTTP)(Session=RAW)) Services Summary... Service "dev12c" has 1 instance(s). Instance "dev12c", status READY, has 1 handler(s) for this service... Service "dev12cXDB" has 1 instance(s). Instance "dev12c", status READY, has 1 handler(s) for this service... Service "prod12c" has 1 instance(s). Instance "prod12c", status READY, has 1 handler(s) for this service... Service "prod12cXDB" has 1 instance(s). Instance "prod12c", status READY, has 1 handler(s) for this service... The command completed successfully

If you need to stop the listener, you can issue the lsnrctl stop command:

$ lsnrctl stop
LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 19-MAY-2013 12:10:40
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.66)(PORT=1521)))
The command completed successfully
$

After changing the listener.ora file, you must restart the listener process. You can do this via the stop and start commands.

To determine what databases the listener is configured to service requests, you can read the listener.ora configuration file. Or you can issue the lsrnctl status command:

$ lsnrctl status
LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 19-MAY-2013 12:13:09
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.66)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias           LISTENER
Version          TNSLSNR for Linux: Version 12.1.0.1.0 - Production
Start Date        19-MAY-2013 12:10:44
Uptime          0 days 0 hr. 2 min. 25 sec
Trace Level        off
Security         ON: Local OS Authentication
SNMP           OFF
Listener Parameter File  /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Listener Log File     /u01/app/oracle/diag/tnslsnr/orasvr01/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.66)(PORT=1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=orasvr01)(PORT=
5500))(Security=(my_wallet_directory=/u01/app/oracle/
admin/dev12c/xdb_wallet))(Presentation=HTTP)(Session=RAW)) Services Summary... Service "dev12c" has 1 instance(s). Instance "dev12c", status READY, has 1 handler(s) for this service... Service "dev12cXDB" has 1 instance(s). Instance "dev12c", status READY, has 1 handler(s) for this service... Service "prod12c" has 1 instance(s). Instance "prod12c", status READY, has 1 handler(s) for this service... Service "prod12cXDB" has 1 instance(s). Instance "prod12c", status READY, has 1 handler(s) for this service... The command completed successfully $

This code shows listening for connections for the dev12c and prod12c databases.

Logs for the listener process are stored in the listener.log file. The listener.log may be in one of these two spots:

  • In ORACLE_HOME/network/admin

  • Under the ADR infrastructure in ADR_BASE/diag/tnslsnr tree

  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win $500. Easy.