Oracle Listener

Summary: in this tutorial, you will learn about the Oracle listener and how to use the listener control commands to manage the listener.

Introduction to the Oracle Listener

The listener is a separate database server process that runs locally on the database server or remotely on the Oracle RAC environment.

The following picture shows the Oracle Database architecture and where the listener locates:

Oracle Listener

When a client request comes, the listener first receives it. And then the listener establishes a connection between the client and the database instance.

Once the client is connected to the database instance successfully, the listener hands over the client connection to the server process.

If the listener stops running, you cannot connect to the Oracle Database anymore. However, all the existing connections will not be affected.

Oracle Listener control commands

To launch the listener control, you use the LSNCTRL command from the command line on Windows or terminal on Linux:

lsnrctrl

Type the help command to see all available options:

LSNRCTL> help
Code language: SQL (Structured Query Language) (sql)

Here is the output:

The following operations are available An asterisk (*) denotes a modifier or extended command: start stop status services version reload save_config trace quit exit set* show*
Code language: JavaScript (javascript)

You can use all of these commands to control the listener. Let’s use the status command:

LSNRCTL> status
Code language: SQL (Structured Query Language) (sql)

The output shows the status of the listener such as alias, version, start date, uptime, trace file, security, listener parameter files listener log files, and listening endpoint summary.

Now, issue the stop command:

LSNRCTL> stop

Once the listener stop listening, you cannot connect to the Oracle Database anymore. Any attempt to connect to the Oracle Database will result in the following error:

ORA-12541: TNS:no listener
Code language: CSS (css)

Note that all connections established before the listener stopped will be unaffected. Because stopping the listener prevents the incoming connections, it does not disconnect those that are already connected.

Use the start command to bring up the listener:

LSNRCTL> start

To exit the listener, you use the exit command:

LSNRCTL> exit
Code language: PHP (php)

Another way to execute the listener command is through the command line without going into the listener control interface. For example, to view the status of the listener, you can use the following command in the command line on Windows or Terminal on Linux:

lsnrctl status

On Windows, the Oracle listener has a service running as a TNS listener. You can also control the status of the listener via this service by stopping and starting it.

In this tutorial, you have learned about the Oracle Listener and how to use the commands to control the listener.

Was this tutorial helpful?