Using the Listener Control Utility to Manage the Listener


Options



Before You Begin

Purpose

This tutorial introduces you to the Listener Control utility which enables you to administer the listener.

Time to Complete

Approximately 30 minutes

Background

Oracle Net Listener is a process that runs on the database server computer. It receives incoming client connection requests and manages the request traffic. Listener configuration information is stored in the listener.ora file and includes one or more listening protocol addresses, information about supported services, and parameters that control its run-time behavior. The listener is configured during the creation of the database. You can use the Listener Control Utility to administer the listener after it is configured.

What Do You Need?

  • Oracle Database 12c Release 2

Prerequisites

Before starting this tutorial, you should have:

  • Installed Oracle Database 12c Release 2

  • Created a database

Viewing the Listener Configuration

Use the Listener Control utility STATUS command to display basic status information about a listener, including a summary of listener configuration settings, listening protocol addresses, and a summary of services registered with the listener. To execute the STATUS command, perform the following steps:

  1. Open a terminal window and execute the oraenv command to set the environment variables.

    $ . oraenv
    ORACLE_SID = [oracle] ? orcl
    The Oracle base has been set to /u01/app/oracle
  2. Execute the lsnrctl status command.

    $ lsnrctl status
    
    LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 25-JUL-2016 06:43:46
    
    Copyright (c) 1991, 2016, Oracle.  All rights reserved.
    
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host01.example.com)(PORT=1521)))
    STATUS of the LISTENER
    ------------------------
    Alias                     LISTENER
    Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
    Start Date                25-JUL-2016 05:30:14
    Uptime                    0 days 1 hr. 13 min. 32 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Listener Parameter File   /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
    Listener Log File         /u01/app/oracle/diag/tnslsnr/host01/listener/alert/log.xml
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host01.example.com)(PORT=1521)))
      (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=host01.example.com)(PORT=5501))(Security=(my_wallet_directory=/u01/app/oracle/admin/orcl/xdb_wallet))(Presentation=HTTP)(Session=RAW))
    Services Summary...
    Service "orcl.example.com" has 1 instance(s).
      Instance "orcl", status READY, has 1 handler(s) for this service...
    Service "orclXDB.example.com" has 1 instance(s).
      Instance "orcl", status READY, has 1 handler(s) for this service...
    The command completed successfully	

    Note: If the Pluggable Database(PDB) is configured, you will see a service for each PDB.

Starting the Listener

The Oracle listener is set to start automatically whenever the host is restarted. If a problem occurs in your system or you have manually stopped the listener, you can restart it by using the lsnrctl start command. To restart the listener, perform the following steps:

  1. For the purposes of this tutorial, stop the listener by executing the lsnrctl stop command.

    $ lsnrctl stop
    
    LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 25-JUL-2016 07:13:34
    
    Copyright (c) 1991, 2016, Oracle.  All rights reserved.
    
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host01.example.com)(PORT=1521)))
    The command completed successfully
  2. Now that the listener is stopped, log in to SQL*Plus as the SYSTEM user using the orcl service name to determine whether you can still connect to the database.

    $ sqlplus system@orcl
    
    SQL*Plus: Release 12.2.0.1.0 Production on Mon Jul 25 07:14:15 2016
    
    Copyright (c) 1982, 2016, Oracle.  All rights reserved.
    
    Enter password: Enter password here
    ERROR:
    ORA-12541: TNS:no listener
    
    
    Enter user-name:

    Exit the prompt by pressing Ctrl + C followed by Enter.

  3. Restart the listener by using the lsnrctl start command.

    $ lsnrctl start
    
    LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 25-JUL-2016 07:43:16
    
    Copyright (c) 1991, 2016, Oracle.  All rights reserved.
    
    Starting /u01/app/oracle/product/12.2.0/dbhome_1/bin/tnslsnr: please wait...
    
    TNSLSNR for Linux: Version 12.2.0.1.0 - Production
    System parameter file is /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
    Log messages written to /u01/app/oracle/diag/tnslsnr/host01/listener/alert/log.xml
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host01.example.com)(PORT=1521)))
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
    
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host01.example.com)(PORT=1521)))
    STATUS of the LISTENER
    ------------------------
    Alias                     LISTENER
    Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
    Start Date                25-JUL-2016 07:43:16
    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.2.0/dbhome_1/network/admin/listener.ora
    Listener Log File         /u01/app/oracle/diag/tnslsnr/host01/listener/alert/log.xml
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host01.example.com)(PORT=1521)))
      (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
    The listener supports no services
    The command completed successfully
  4. Check the listener status by executing the lsnrctl status command.

    $ lsnrctl status
    
    LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 25-JUL-2016 06:43:46
    
    Copyright (c) 1991, 2016, Oracle.  All rights reserved.
    
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host01.example.com)(PORT=1521)))
    STATUS of the LISTENER
    ------------------------
    Alias                     LISTENER
    Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
    Start Date                25-JUL-2016 05:30:14
    Uptime                    0 days 1 hr. 13 min. 32 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Listener Parameter File   /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
    Listener Log File         /u01/app/oracle/diag/tnslsnr/host01/listener/alert/log.xml
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host01.example.com)(PORT=1521)))
      (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=host01.example.com)(PORT=5501))(Security=(my_wallet_directory=/u01/app/oracle/admin/orcl/xdb_wallet))(Presentation=HTTP)(Session=RAW))
    Services Summary...
    Service "orcl.example.com" has 1 instance(s).
      Instance "orcl", status READY, has 1 handler(s) for this service...
    Service "orclXDB.example.com" has 1 instance(s).
      Instance "orcl", status READY, has 1 handler(s) for this service...
    The command completed successfully

    Note: If the PDB is configured, you will see a service for each PDB.

  5. Once again log in to SQL*Plus as the SYSTEM user to verify you can now connect to the database.

    $ sqlplus system@orcl
    
    SQL*Plus: Release 12.2.0.1.0 Production on Mon Jul 25 07:45:15 2016
    
    Copyright (c) 1982, 2016, Oracle.  All rights reserved.
    
    Enter password: Enter password here
    Last Successful login time: Mon Jul 25 2016 07:31:56 +00:00
    
    Connected to:
    Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
    
    SQL>
  6. Log in to Enterprise Manager Database Express as the SYSTEM user to verify you can access the database.

    Enterprise Manager login page
    Description of this image
  7. The Database Home page is displayed. Log out of Enterprise Manager Database Express.

Want to Learn More?