对于DBA来说,启动和关闭oracle监听器是很基础的任务,但是Linux系统管理员或者程序员有时也需要在开发数据库中做一些基本的DBA操作,因此了解一些基本的管理操作对他们来说很重要。
本文将讨论用LSNRCTL命令启动、关闭和查看监听器的状态的方法。
怎样启动、关闭和重新启动oracle监听器 在启动、关闭或者重启oracle监听器之前确保使用lsnrctl status命令检查oracle监听器的状态。除了得到监听器的状态之外,你还可以从lsnrctl status命令的输出中得到如下的信息:如果oracle监听器没用运行,你将得到如下的信息
- $lsnrctlstatus
- LSNRCTLforLinux:Version11.1.0.6.0-Productionon04-APR-200916:27:39
- Copyright(c)1991,2007,Oracle.Allrightsreserved.
- Connectingto(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.2)(PORT=1521)))
- TNS-12541:TNS:nolistener
- TNS-12560:TNS:protocoladaptererror
- TNS-00511:Nolistener
- LinuxError:111:Connectionrefused
- Connectingto(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
- TNS-12541:TNS:nolistener
- TNS-12560:TNS:protocoladaptererror
- TNS-00511:Nolistener
- LinuxError:2:Nosuchfileordirectory
如果oracle监听器正在运行,你将得到如下信息
- Linux:Version11.1.0.6.0-Productionon04-APR-200916:27:02
- STATUSoftheLISTENER
- ————————
- AliasLISTENER
- VersionTNSLSNRLinux:Version11.1.0.6.0-Production
- StartDate29-APR-200918:43:13
- Uptime6days21hr.43min.49sec
- TraceLeveloff
- SecurityON:LocalOSAuthentication
- SNMPOFF
- ListenerParameterFile/u01/app/oracle/product/11.1.0/network/admin/listener.ora
- ListenerLogFile/u01/app/oracle/diag/tnslsnr/devdb/listener/alert/log.xml
- ListeningEndpointsSummary…
- (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.2)(PORT=1521)))
- (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
- ServicesSummary…
- Service“devdb”has1instance(s).
- Instance“devdb”,statusUNKNOWN,has1handler(s)forthisservice…
- Service“devdb.thegeekstuff.com”has1instance(s). @H_301_154@Service“devdbXDB.thegeekstuff.com”has1instance(s).
- Service“devdb_XPT.thegeekstuff.com”has1instance(s).
- Thecommandcompletedsuccessfully
2.启动oracle监听器
如果oracle监听器没用运行,你可以用lsnrctl start命令启动oracle监听器,该命令将启动所有的监听器,如果你只想启动特定的监听器,可以再start后面指定监听器的名字,例如:lsnrctl start [listener-name]。
- $lsnrctlstart
- Linux:Version11.1.0.6.0-Productionon04-APR-200916:27:42
- Starting/u01/app/oracle/product/11.1.0/bin/tnslsnr:pleasewait…
- TNSLSNRSystemparameterfileis/u01/app/oracle/product/11.1.0/network/admin/listener.ora
- Logmessageswrittento/u01/app/oracle/diag/tnslsnr/devdb/listener/alert/log.xml
- Listeningon:(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.2)(PORT=1521)))
- Listeningon:(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
- StartDate04-APR-200916:27:42
- Uptime0days0hr.0min.0sec
- Thecommandcompletedsuccessfully
3.关闭oracle监听器
如果oracle监听器正在运行,可以使用lsnrctl stop命令关闭oracle监听器,该命令将关闭所有的监听器,如果你只想关闭特定的监听器,可以再stop后面指定监听器的名字,例如:lsnrctl stop [listener-name]
- $lsnrctlstop
- Linux:Version11.1.0.6.0-Productionon04-APR-200916:27:37
- Thecommandcompletedsuccessfully
4.重启oracle监听器
用lsnrctl reload重启监听器,此命令可以代替lsnrctl stop和lsnrctl start。重启将会在不需要关闭和启动监听器的情况下读取listener.ora的配置。
- $lsnrctlreload
- Linux:Version11.1.0.6.0-Productionon04-APR-200917:03:31
- Thecommandcompletedsuccessfully
Oracle监听器帮助
1.查看所有的监听器命令
lsnrctl hep命令可以显示所有可用的监听器命令。在oracle11g中其输出如下:
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 will reload the oracle listener SID and parameter files. This is equivalent to lsnrctl stop and lsnrctl start. save_config - This will save the current settings to the listener.ora file and also take a backup of the listener.ora file before overwriting it. If there are no changes,it will display the message “No changes to save for LISTENER” trace - Enable the tracing at the listener level. The available options are ‘trace OFF’,‘trace USER’,‘trace ADMIN’ or ‘trace SUPPORT’ spawn - Spawns a new with the program 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.- $lsnrctlhelp
- Linux:Version11.1.0.6.0-Productionon04-APR-200916:12:09
- Thefollowingoperationsareavailable
- Anasterisk(*)denotesamodifierorextendedcommand:
- startstopstatus
- servicesversionreload
- save_configtracespawn
- change_passwordquitexit
- set*show*
2.得到指定监听器命令的详细帮助信息
可以使用lsnrctl help得到指定的命令的详细帮助信息。如下所示
- $lsnrctlhelpshow
- Linux:Version11.1.0.6.0-Productionon04-APR-200916:22:28
- Thefollowingoperationsareavailableaftershow
- Anasterisk(*)denotesamodifierorextendedcommand:
- rawmodedisplaymode
- rulestrc_file
- trc_directorytrc_level
- log_filelog_directory
- log_statuscurrent_listener
- inbound_connect_timeoutstartup_waittime
- snmp_visiblesave_config_on_stop
- dynamic_registration