Starting and shutting down Oracle listeners is a fundamental task for DBAs, but Linux system administrators or programmers sometimes need to do some basic DBA work in the development database, so it is important for them to understand some basic administrative operations.
This article discusses how to start, close, and view the state of the listener with the LSNRCTL command.
How to start, shut down, and restart an Oracle listener
Ensure that the status of the Oracle listener is checked using the LSNRCTL status command before starting, shutting down, or restarting the Oracle listener. In addition to getting the listener status, you can also get the following information from the output of the Lsnrctl status command:
- Boot time of the listener
- Elapsed time of the listener
- The location of the listener parameter file Listener.ora, usually located in the $oracle_home/network/admin directory
- Location of listener log files
If the Oracle listener doesn't work, you'll get the following information
[C-sharp]View Plaincopy
- $ LSNRCTL Status
- Lsnrctl for linux:version 11.1.0.6.0-production on 04-apr-2009 16:27:39
- Copyright (c) 1991, Oracle. All rights reserved.
- Connecting to (Description= (address= (protocol=tcp) (host=192.168.1.2) (port=1521)))
- Tns-12541:tns:no Listener
- Tns-12560:tns:protocol Adapter Error
- Tns-00511:no Listener
- Linux Error:111:connection refused
- Connecting to (Description= (address= (PROTOCOL=IPC) (Key=extproc)))
- Tns-12541:tns:no Listener
- Tns-12560:tns:protocol Adapter Error
- Tns-00511:no Listener
- Linux error:2: No such file or directory
If the Oracle listener is running, you will get the following information
[C-sharp]View Plaincopy
- $ LSNRCTL Status
- Lsnrctl for linux:version 11.1.0.6.0-production on 04-apr-2009 16:27:02
- Copyright (c) 1991, Oracle. All rights reserved.
- Connecting to (Description= (address= (protocol=tcp) (host=192.168.1.2) (port=1521)))
- STATUS of the LISTENER
- ————————
- Alias LISTENER
- Version Tnslsnr for linux:version 11.1.0.6.0-production
- Start Date 29-apr-2009 18:43:13
- Uptime 6 hr. Min. sec
- Trace level off
- Security on:local OS Authentication
- SNMP OFF
- Listener Parameter File/u01/app/oracle/product/11.1.0/network/admin/listener.ora
- Listener Log File/u01/app/oracle/diag/tnslsnr/devdb/listener/alert/log.xml
- Listening Endpoints Summary ...
- (Description= (address= (protocol=tcp) (host=192.168.1.2) (port=1521)))
- (Description= (address= (PROTOCOL=IPC) (Key=extproc)))
- Services Summary ...
- Service "Devdb" has 1 instance (s).
- Instance "Devdb", status UNKNOWN, have 1 handler (s) for the This service ...
- Service "Devdb.thegeekstuff.com" has 1 instance (s).
- Instance "Devdb", status ready, have 1 handler (s) for the This service ...
- Service "DevdbXDB.thegeekstuff.com" has 1 instance (s).
- Instance "Devdb", status ready, have 1 handler (s) for the This service ...
- Service "Devdb_XPT.thegeekstuff.com" has 1 instance (s).
- Instance "Devdb", status ready, have 1 handler (s) for the This service ...
- The command completed successfully
2. Start the Oracle Listener
If the Oracle listener is not running, you can start the Oracle listener with the LSNRCTL Start command, which will start all listeners and, if you only want to start a specific listener, you can specify the listener name after start, for example: Lsnrctl start [ Listener-name].
[C-sharp]View Plaincopy
- $ lsnrctl Start
- Lsnrctl for linux:version 11.1.0.6.0-production on 04-apr-2009 16:27:42
- Copyright (c) 1991, Oracle. All rights reserved.
- Starting/u01/app/oracle/product/11.1.0/bin/tnslsnr:please wait ...
- Tnslsnr for linux:version 11.1.0.6.0-production
- System parameter file Is/u01/app/oracle/product/11.1.0/network/admin/listener.ora
- Log messages Written To/u01/app/oracle/diag/tnslsnr/devdb/listener/alert/log.xml
- Listening on: (Description= (Address= (protocol=tcp) (host=192.168.1.2) (port=1521)))
- Listening on: (Description= (Address= (PROTOCOL=IPC) (Key=extproc)))
- Connecting to (Description= (address= (protocol=tcp) (host=192.168.1.2) (port=1521)))
- STATUS of the LISTENER
- ————————
- Alias LISTENER
- Version Tnslsnr for linux:version 11.1.0.6.0-production
- Start Date 04-apr-2009 16:27:42
- 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/11.1.0/network/admin/listener.ora
- Listener Log File/u01/app/oracle/diag/tnslsnr/devdb/listener/alert/log.xml
- Listening Endpoints Summary ...
- (Description= (address= (protocol=tcp) (host=192.168.1.2) (port=1521)))
- (Description= (address= (PROTOCOL=IPC) (Key=extproc)))
- Services Summary ...
- Service "Devdb" has 1 instance (s).
- Instance "Devdb", status UNKNOWN, have 1 handler (s) for the This service ...
- The command completed successfully
3. Turn off the Oracle Listener
If the Oracle listener is running, you can use the Lsnrctl Stop command to turn off the Oracle listener, which will shut down all listeners and, if you just want to turn off a specific listener, you can specify the listener name after stop, for example: Lsnrctl stop [ Listener-name]
[C-sharp]View Plaincopy
- $ lsnrctl Stop
- Lsnrctl for linux:version 11.1.0.6.0-production on 04-apr-2009 16:27:37
- Copyright (c) 1991, Oracle. All rights reserved.
- Connecting to (Description= (address= (protocol=tcp) (host=192.168.1.2) (port=1521)))
- The command completed successfully
4. Restart the Oracle Listener
Restart the listener with Lsnrctl reload, this command can replace Lsnrctl stop and lsnrctl start. Rebooting will read the configuration of the Listener.ora without the need to shut down and start the listener.
[C-sharp]View Plaincopy
- $ lsnrctl Reload
- Lsnrctl for linux:version 11.1.0.6.0-production on 04-apr-2009 17:03:31
- Copyright (c) 1991, Oracle. All rights reserved.
- Connecting to (Description= (address= (protocol=tcp) (host=192.168.1.2) (port=1521)))
- The command completed successfully
Oracle Listener Help
1. View all listener commands
The Lsnrctl hep command can display all available listener commands. In oracle11g, its output is as follows:
- start -Start the Oracle listener
- Stop -Stop the Oracle listener
- Status -Display the current status of the Oracle listener
- Services -Retrieve the Listener services information
- version -Display The Oracle Listener version information
- Reload -this would reload the Oracle Listener SID and parameter files. This is equivalent to Lsnrctl stop and lsnrctl start.
- Save_config -This would save the current settings to the Listener.ora file and also take a backup of the listener . ora file before overwriting it. If There is no changes, it would display the message "No changes to save for LISTENER"
- Trace -Enable The tracing at the listener level. The available options is ' Trace OFF ', ' Trace USER ', ' Trace ADMIN ' or ' trace support '
- Spawn -Spawns a new with the Spawn_alias mentioned in the Listener.ora file
- Change_password -Set The new password to the Oracle Listener (or) Change the existing listener password.
- Show -Display log files and other relevant listener information.
[C-sharp]View Plaincopy
- $ lsnrctl Help
- Lsnrctl for linux:version 11.1.0.6.0-production on 04-apr-2009 16:12:09
- Copyright (c) 1991, Oracle. All rights reserved.
- The following operations is available
- An asterisk (*) denotes a modifier or extended command:
- Start Stop status
- Services version Reload
- Save_config Trace Spawn
- Change_password quit exit
- set* show*
2. Get detailed help information for the specified listener command
You can use Lsnrctl help to get the details of the specified command. As shown below
[C-sharp]View Plaincopy
- $ lsnrctl Help Show
- Lsnrctl for linux:version 11.1.0.6.0-production on 04-apr-2009 16:22:28
- Copyright (c) 1991, Oracle. All rights reserved.
- The following operations is available after show
- An asterisk (*) denotes a modifier or extended command:
- Rawmode DisplayMode
- Rules Trc_file
- Trc_directory Trc_level
- Log_file Log_directory
- Log_status Current_listener
- Inbound_connect_timeout Startup_waittime
- Snmp_visible Save_config_on_stop
- Dynamic_registration
Startup and shutdown of the Oracle lsnrctl------Listener