这里我们看2个比较常用的操作。
1. 停止写listener log
在某些特定的场合可能会有这样的需求。控制这个功能的参数是LOG_STATUS。 官网对这个参数的说明:To turn listenerlogging on or off.
--在OS层面直接使用:
lsnrctl SET LOG_STATUS {on | off}
--在LSNRCTL 工具中使用:
LSNRCTL> SET LOG_STATUS {on | off}
--查看log_status状态:
LSNRCTL> show log_status
Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.4)(PORT=1521)))
LISTENER parameter "log_status"set to ON
The command completed successfully
说明:
之前遇到一个很奇怪的问题,就是log_status状态是on,但是listener就是不写日志,再次手工设置为on后,又正常写日志。
LSNRCTL> setlog_status off
Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.4)(PORT=1521)))
LISTENER parameter "log_status"set to OFF
The command completed successfully
LSNRCTL> showlog_status
Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.4)(PORT=1521)))
LISTENER parameter "log_status"set to OFF
The command completed successfully
LSNRCTL> setlog_status on
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.4)(PORT=1521)))
LISTENER parameter "log_status"set to ON
The command completed successfully
LSNRCTL> showlog_status
Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.4)(PORT=1521)))
LISTENER parameter "log_status" setto ON
The command completed successfully
2. 保存listener 的修改
保存又参数:SAVE_CONFIG控制,官网的说明:
To save the current configuration state of the listener, includingtrace level, trace file, trace directory, and logging tothe listener.ora file. Any changes are stored in listener.ora,preserving formatting, comments, and case as much as possible. Beforemodification of the listener.ora file, a backup of the file,called listener.bak, is created.
我们在第一部分修改了log_status 的配置,如果没有保存,那么在重启监听之后,修改就会失效,所以这里要保存,才能永久的生效。
LSNRCTL> save_config
Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.4)(PORT=1521)))
Saved LISTENER configuration parameters.
Listener Parameter File /u01/app/Oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Old Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.bak
The command completed successfully
注意:
这里使用的是默认的listner,如果不是默认的,就需要加上listener_name. 如:
LSNRCTL> SAVE_CONFIG listener_name
保存之后,修改的内容就会写入listener.ora 文件。
这里是我的的测试环境,其中listener.ora 文件多了如下内容:
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
#----ADDED BY TNSLSNR 22-DEC-201221:59:58---
LOGGING_LISTENER = ON
#--------------------------------------------