学无止境
分类: Oracle
2013-08-19 16:25:21
监听器控制器可以在监听启动时管理和查看监听。
使用lsnrctl命令设置监听参数
在监听启动时,可以使用lsnrctl命令进入到 LSNRCTL> 监听管理下,设置一些监听参数。
help命令可以看到可用的命令列表。
默认修改的是1521端口的监听,如果有多个监听,想要设置某个监听的参数,可以使用:
set current_listener 监听名
例如设置listener2的监听日志目录
LSNRCTL> set current_listener listener2
Current Listener is listener2
LSNRCTL> set log_directory
Parameter Value: D:\liaody
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=support-PC)(PORT=1421)))
listener2 parameter "log_directory" set to D:\liaody
The command completed successfully
如果希望在这里设置的参数能在监听关闭后保存到listener.ora文件中,可以用命令:
set save_config_on_stop on
或事先在listener.ora设置了:
SAVE_CONFIG_ON_STOP_listener_name=true
之后启动的监听即可保存设置到文件中。
配置监听密码
设置监听密码可以避免监听不小心被关闭,或是在运行是被同组的未经授权其它用户关闭或修改
这里举例设置加密口令的方法。
LSNRCTL> set current_listener listener
Current Listener is listener
LSNRCTL> set save_config_on_stop on
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
listener parameter "save_config_on_stop" set to ON
The command completed successfully
LSNRCTL> change_password
Old password:
New password:
Reenter new password:
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
Password changed for listener
The command completed successfully
设置了密码之后,只有启动用户可以不输入密码直接将其关闭,用同组的其它关闭都会报以下错:
LSNRCTL> stop
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-01190: The user is not authorized to execute the requested listener command
需要输入密码后,才能关闭监听
LSNRCTL> set password
Password:
The command completed successfully
LSNRCTL> stop
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
The command completed successfully
listener.ora文件中会自动添加以下内容:
#----ADDED BY TNSLSNR 14-MAY-2012 15:40:06---
SAVE_CONFIG_ON_STOP_LISTENER = ON
PASSWORDS_LISTENER = 1DF5C2FD0FE9CFA2
#--------------------------------------------