LSNRCTL command [listener_name]
In this syntax:
LSNRCTL | Specifies the name of the tool that controls the listener. In some operating systems, this fixed parameter is case sensitive. If the operating system is case sensitive, enter LSNRCTL in lowercase. |
command | Specifies the action to be performed. |
listener_name | Specifies the listener name defined in LISTENER.ORA. If listener_name is not included, the default value LISTENER is used. |
LSNRCTL> dbsnmp_start
iris[331] lsnrctl LSNRCTL for SunOS: Version 2.3.1.1.0 - Beta on 17-AUG-95 17:15:02 Copyright (c) Oracle Corporation 1994. All rights reserved. Welcome to LSNRCTL, type "help" for information.
LSNRCTL> help The following operations are available An asterisk (*) denotes a modifier or extended command: start stop status services version reload trace spawn dbsnmp_start dbsnmp_stop dbsnmp_status change_password quit exit set* show*
LSNRCTL> set The following operations are available after set An asterisk (*) denotes a modifier or extended command: password trc_file trc_directory trc_level log_file log_directory log_status current_listener connect_timeout startup_waittime use_plugandplay
LSNRCTL> show The following operations are available after show An asterisk (*) denotes a modifier or extended command: trc_file trc_directory trc_level log_file log_directory log_status current_listener connect_timeout startup_waittime snmp_visible use_ckpfile use_plugandplay
change_password
The control utility prompts you for your old password, then for the new one. It asks you to re-enter the new one, then changes it.
Note: Neither the old nor the new password displays during this procedure.
The following is an example of changing a password:
iris> lsnrctl LSNRCTL for SunOS: Version 2.3.2.0.0 - on 10-Sep-95 18:59:34 Copyright (c) Oracle Corporation 1994. All rights reserved. Welcome to LSNRCTL, type "help" for information. LSNRCTL> change_password Old password: New password: Reenter new password: Connecting to (ADDRESS=(PROTOCOL=ipc)(KEY=iris)) Password changed for LISTENER The command completed successfully LSNRCTL>
For example, you might create a program called NSTEST, and manually add the following to the LISTENER.ORA file:
nstest = (PROGRAM=(NAME=nstest)(ARGS=test1)(ENVS='ORACLE_HOME=/usr/oracle'))
To run the NSTEST program, you would enter the following:
lsnrctl spawn nstest
Note: You must have set a valid password if one is listed in the LISTENER.ORA parameter PASSWORDS_listener_name to be able to use this command.
Note: You must have set a valid password if one is listed in the LISTENER.ORA paramete,r PASSWORDS_listener_name, to be able to use this command.
Note: You must have set a valid password, if one is listed in the LISTENER.ORA file parameter PASSWORDS_listener_name, to be able to use this command.
Note: You must have set a valid password, if one is listed in the LISTENER.ORA file parameter PASSWORDS_listener_name, to be able to use this command.
For detailed information on how to use tracing, see the Oracle Network Products Troubleshooting Guide.
DBSNMP START must be run locally--you cannot run it remotely.
DBSNMP STOP must be run locally--you cannot run it remotely.
DBSNMP STATUS must be run on the same node the Oracle database is on.
The preferred, secure way to enter your password is in interactive mode. Enter the command from within LSNRCTL, for example,
LSNRCTL> SET PASSWORD
The Listener Control Utility responds:
enter listener password:
When you enter your password and press [Return], the password is not echoed on the terminal. You receive the message:
Command successful
Note: You must enter the SET PASSWORD command before you can stop the listener (with the STOP [listener_name)
Note: The listener supports encrypted and unencrypted passwords.
Note: You must have set a valid password, if one is listed in the LISTENER.ORA file parameter PASSWORDS_listener_name to be able to use this command.
For detailed information on how to use tracing, see the Oracle Network Products Troubleshooting Guide.
For example, the following command sets the name of the file that contains listener trace information:
LSNRCTL> set trc_file list.trc
The computer output would be something like the following:
Connecting to (ADDRESS=(PROTOCOL=ipc)(KEY=iris)) LISTENER parameter "trc_file" set to list.trc The command completed successfully
For example, the following command sets the directory in which the trace file is placed:
LSNRCTL> set trc_directory /usr/oracle/admin
The computer output would be something like the following:
Connecting to (ADDRESS=(PROTOCOL=ipc)(KEY=iris)) LISTENER parameter "trc_directory" set to /usr/oracle/admin The command completed successfully
For example, the following command sets the name of the file that contains listener log information:
LSNRCTL> set log_file list.trc
The computer output would be something like the following:
Connecting to (ADDRESS=(PROTOCOL=ipc)(KEY=iris)) LISTENER parameter "log_file" set to list.log The command completed successfully
For example, the following command sets the directory in which the log file is placed:
LSNRCTL> set log_directory /usr/oracle/admin
The computer output would be something like the following:
Connecting to (ADDRESS=(PROTOCOL=ipc)(KEY=iris)) LISTENER parameter "log_directory" set to /usr/oracle/admin The command completed successfully
For example, suppose there were two listeners on a node, LISTENER and LSNR1. If you wanted to set or show parameters for LSNR1, you would first need to send the following command from within LSNRCTL:
LSNRCTL> set current_listener lsnr1
Any subsequent LSNRCTL commands within the same LSNRCTL session would then apply to LSNR1, unless CURRENT_LISTENER were reset. For example, if the current listener had been set to LSNR1, then the STAT command would produce something like the following output:
LSNRCTL> stat
Connecting to (ADDRESS=(PROTOCOL=IPC)(KEY=IRIS)) STATUS of the LISTENER ----------------------- Alias lsnr1 Version TNSLSNR for SunOS: Version 2.3.1.1.0- Beta Start Date 18-Aug-95 11:25:45 Uptime 0 days 0 hr. 0 min. 3 sec Trace Level admin Security OFF SNMP ON Listener Parameter File /etc/oracle/network/admin/listener.ora Listenr Log File /etc/oracle/network/log/lsnr1.log Listener Trace File /etc/oracle/network/trace/lsnr1.trc Services Summary... db1 has 1 service handler(s) The command completed successfully
You can also display the current listener by using the LSNRCTL SHOW command.
Note: You must enter SET CURRENT_LISTENER from within the LSNRCTL utility. When you exit the utility, the setting will be lost.
LSNRCTL> set connect_timeout 20
The computer output would be something like the following:
Connecting to (ADDRESS=(PROTOCOL=ipc)(KEY=iris)) LISTENER parameter "connect_timeout" set to 20 The command completed successfully
lSNRCTL> set startup_waittime 10
The computer output would be something like the following:
Connecting to (ADDRESS=(PROTOCOL=ipc)(KEY=iris)) LISTENER parameter "startup_waittime" set to 10 The command completed successfully
LSNRCTL> set use_plugandplay ON|OFF
By default, the value of this parameter is OFF. If Oracle Names version 2 has been installed, and you want the listener to use the Dynamic Discovery Option (that is, to register itself with a well-known Names Server, set it to ON. You can also set the value in LISTENER.ORA through Oracle Network Manager, which places a slightly different parameter into LISTENER.ORA, as follows:
use_plugandplay_listener_name=[ON|OFF]
If the Dynamic Discovery Option is enabled, you can use the LSNRCTL STATUS command to see whether a service has registered itself. For example:
LSNRCTL> stat lsnr1
Connecting to (ADDRESS=(PROTOCOL=IPC)(KEY=IRIS)) STATUS of the LISTENER ----------------------- Alias lsnr1 Version TNSLSNR for SunOS: Version 2.3.1.1.0- Beta Start Date 18-Aug-95 11:25:45 Uptime 0 days 0 hr. 1 min. 49 sec Trace Level admin Security OFF SNMP ON Listener Parameter File /etc/oracle/network/admin/listener.ora Listener Log File /etc/oracle/network/log/lsnr1.log Listener Trace File /etc/oracle/network/trace/lsnr1.trc Services Summary... db1 (Registered) has 1 service handler(s) The command completed successfully
In addition, there are two other parameters that can be shown, but not set, through LSNRCTL.
LSNRCTL> show snmp_visible
The computer output would be something like the following:
Connecting to (ADDRESS=(PROTOCOL=ipc)(KEY=iris)) LISTENER parameter "snmp_visible" set to ON The command completed successfully
Note: The SNMP_VISIBLE parameter can be displayed, but not set, through LSNRCTL:
LSNRCTL> show use_ckpfile
The computer output would be something like the following:
Connecting to (ADDRESS=(PROTOCOL=ipc)(KEY=iris)) LISTENER parameter "use_ckpfile" set to OFF The command completed successfully
If USE_CKPFILE_listener_name is not set in LISTENER.ORA, and you use LSNRCTL SET commands to change listener parameters, when you stop the listener, LSNRCTL sends a message reminding you that the changes you have made are not persistent.
Note: You cannot set this parameter using LSNRCTL; it must be set in LISTENER.ORA. For more information about the use of checkpoint files, see "Persistent Changes" later in this chapter.
use_ckpfile_listener_name=ON
If this parameter is in the LISTENER.ORA file, the parameters you set using LSNRCTL are saved to a checkpoint file, listener_name.CKP, either in the TNS_ADMIN directory if one exists, or in the ORACLE_HOME/NETWORK/ADMIN directory. The values in this checkpoint file will override the values set in LISTENER.ORA.
If the USE_CKPFILE parameter is set to OFF in LISTENER.ORA, the values set by LSNRCTL are lost when the listener is restarted or the LISTENER.ORA parameters are reloaded. The default is for USE_CKPFILE to be OFF.
Note: If checkpointing is enabled and parameters in LISTENER.ORA are changed, the changes will not be visible because they are overridden by the parameters in the checkpoint file. If you want the changes in LISTENER.ORA to be visible, set the value of USE_CKPFILE to OFF and use the LSNRCTL RELOAD command to reread the LISTENER.ORA file.
LSNRCTL START
Alternatively, you can enter LSNRCTL on the command line and then enter START from the program prompt.
To start a listener configured in the LISTENER.ORA file with a name other than LISTENER, include that name. For example, if the listener name is TCP_LSNR, enter:
LSNRCTL START TCP_LSNR
Or, from the LSNRCTL program prompt, just enter:
LSNRCTL> START TCP_LSNR
LSNRCTL STOP
To stop a running listener defined in LISTENER .ORA as TCP_LSNR, use the command:
LSNRCTL STOP TCP_LSNR
Remember, if there are any passwords in the LISTENER.ORA file, you must use the SET PASSWORD command before you can use the STOP command. You must set the password from within the LSNRCTL program; you cannot set it from the operating system command line. The method for setting the password depends on whether you are using the encrypted password feature. If you are not using an encrypted password, enter the password on the LSNRCTL command line. For example, the following commands stop the TCP_LSNR using an unencrypted password:
LSNRCTL LSNRCTL> SET PASSWORD password LSNRCTL> STOP TCP_LSNR
If you are using an encrypted password, enter the password in interactive mode. For example, the following commands stop the listener named TCP_LSNR:
LSNRCTL LSNRCTL> SET PASSWORD
Enter listener password (password is not displayed) Command successful LSNRCTL> STOP TCP_LSNR
Stopping a listener when in batch mode is not recommended, because to do so you must include your password in a cleartext batch file, which would threaten your security. However, if you are not using an encrypted password, stopping a listener can be done by redirecting input into the command interpreter.
Note: You should not stop the listener in batch mode if it requires an encrypted password.
Different operating systems use different syntax. An example for VMS and two alternative methods for UNIX follow.
To stop a listener in batch mode on VMS, create a DCL script, with a name like LSNRSTOP.COM, as follows:
$ lsnrctl set password password stop listener_name exit
When you want to stop the listener, run the script as follows:
@LSNRSTOP
On a UNIX system or on OS/2, the following procedure would be effective:
Create a file with a name like LSNRSTOP that contains the following lines:
set password password stop listener_name
You can then stop the listener from the command line by entering:
lsnrctl < LSNRSTOP
Alternatively, in UNIX you can stop the listener by creating a shell script named something like "lsnrstop". The shell script would look something like this::
lsnrctl <<! set password password stop listener_name exit !
You can then stop the listener from the command line by entering:
LSNRSTOP
Again, Oracle Corporation recommends against stopping a listener in batch mode because of the need to expose your password.
Note: Be careful when stopping a listener. On some platforms and with some protocols, when a listener is stopped any SQL*Net connections currently running are shut down. In some situations the connections continue, but it is then not possible to start the listener again until the running processes have been closed. It is good practice to send a warning message to all network users before stopping a listener.
LSNRCTL STATUS
Following is sample output from a status report of a UNIX listener :
LSNRCTL for SunOS: Version 2.2.2.0 - Production on 15-FEB-95 07:07:10 Copyright (c) Oracle Corporation 1995. All rights reserved. Connecting to (ADDRESS=(PROTOCOL=IPC)(HOST=orchid)(port=1334)) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for SunOS: Version 2.2.2.0 - Production Start Date 10-FEB-94 07:06:34 Uptime 0 days 0 hr. 0 min. 44 sec Trace Level ADMIN Security ON SNMP ON Listener Parameter File /private1/dvl/7012/network/admin/listener.ora Listener Log File /private1/dvl/7012/network/log/listener.log Listener Trace File /private1/dvl/7012/network/trace/listener.trc Listening on (ADDRESS=(PROTOCOL=tcp)(HOST=orchid) (port=1334))) (ADDRESS=(PROTOCOL=decnet)(node=23.106) (object=orchid))) Services Summary... orchid has 1 service handlers The command completed successfully
LSNRCTL>[SET PASSWORD password] LSNRCTL> SERVICES
The output of a LSNRCTL SERVICES command follows:
LSNRCTL for SunOS: Version 2.1.3.0.0 - Production on 10-FEB-94 07:14:55 Copyright (c) Oracle Corporation 1993. All rights reserved. Connecting to (ADDRESS=(PROTOCOL=IPC)(KEY=ruth)) Services Summary... ruth has 1 service handlers DEDICATED SERVER established:99 refused:0 The LSNRCTL command completed successfully
In this example, the LSNRCTL SERVICES command returned the information that the listener had established 99 connections using a dedicated server process and refused none.
In the following example the LSNRCTL SERVICES command returns information about four types of service handlers.
LSNRCTL for SunOS: Version 2.2.2.0.0 - Production on 15-Mar-1995 17:41:12
Copyright (c) Oracle Corporation 1994. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=ipc)(KEY=orchid))
Services Summary...
listener has 4 service handlers
DEDICATED SERVER established:0 refused:0
PRESPAWNED SERVER established:0 refused:0 current:0 max:1 state:ready
PID:15439
(ADDRESS=(PROTOCOL=ipc)(DEV=4)(KEY=#15439.1))
PRESPAWNED SERVER established:5 refused:0 current:0 max:1 state:ready
PID:15441
(ADDRESS=(PROTOCOL=tcp)(DEV=4)(HOST=139.185.22.25)(PORT=3334))
DISPATCHER established:30 refused:0 current:7 max:21 state:ready
D000 (machine: orchid, pid: 15406)
(ADDRESS=(PROTOCOL=tcp)(DEV=7)(HOST=139.185.22.25)(PORT=3330))
The command completed successfully
This message shows that since this listener has been running, it has made a total of five connections using a prespawned server for TCP/IP, and that it has one running at this time. It also shows that there are seven connections currently established using a multi-threaded server dispatcher, with a total of 30 established since the process started.