listener操作

1. 停止写listener log
在某些特定的场合可能会有这样的需求。控制这个功能的参数是LOG_STATUS。 官网对这个参数的说明:To turn listenerlogging on or off.
 
--在OS层面直接使用:
lsnrctl SET LOG_STATUS {on | off}
$ lsnrctl show  LOG_STATUS 
 
--在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> set log_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> show log_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> set log_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> show log_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
#--------------------------------------------
 
 
3. 加密listener
 
有时候处于安全考虑,会需要对listener设置密码。
 
3.1 设置监听名
如果有多个监听,那么需要先设置当前的监听
LSNRCTL>set current_listener listener_name
 
 
3.2 设置密码
使用change_password设置listener口令。
 
LSNRCTL> change_password
Old password:    --如果原来没有设置口令就直接回车,否则输入原来的口令
New password:
Reenter new password:
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.4)(PORT=1521)))
Password changed for LISTENER
The command completed successfully
 
--保存密码:
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
 
 
--加密之前:
[oracle@dave ~]$ lsnrctl status
 
LSNRCTL for Linux: Version 11.2.0.3.0 -Production on 22-DEC-2012 22:54:55
 
Copyright (c) 1991, 2011, Oracle.  All rights reserved.
 
Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.4)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version11.2.0.3.0 - Production
Start Date                22-DEC-2012 21:57:46
Uptime                    0 days 0 hr. 57 min. 9 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File  /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/dave/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.4)(PORT=1521)))
Services Summary...
Service "dave" has 2 instance(s).
 Instance "dave", status UNKNOWN, has 1 handler(s) for thisservice...
 Instance "dave", status READY, has 1 handler(s) for thisservice...
Service "daveXDB" has 1instance(s).
 Instance "dave", status READY, has 1 handler(s) for thisservice...
 
 
--加密之后:
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.4)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version11.2.0.3.0 - Production
Start Date                22-DEC-2012 22:56:19
Uptime                    0 days 0 hr. 11 min. 2 sec
Trace Level               off
Security                  ON: Password or Local OSAuthentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File        /u01/app/oracle/diag/tnslsnr/dave/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.4)(PORT=1521)))
Services Summary...
Service "dave" has 2 instance(s).
 Instance "dave", status UNKNOWN, has 1 handler(s) for thisservice...
 Instance "dave", status READY, has 1 handler(s) for thisservice...
Service "daveXDB" has 1instance(s).
 Instance "dave", status READY, has 1 handler(s) for this service...
The command completed successfully
 
 
--在listener.ora 文件中也会多一个配置参数:
[oracle@dave ~]$ cat/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

#----ADDED BY TNSLSNR 22-DEC-201221:59:58---
LOGGING_LISTENER = ON
#--------------------------------------------
 
#----ADDED BY TNSLSNR 22-DEC-201223:06:31---
PASSWORDS_LISTENER =1DF5C2FD0FE9CFA2
#--------------------------------------------
[oracle@dave ~]$
 
3.3 解除密码
listener的密码策略是防止stop,所以在stop时需要确认密码,在start时不需要输入密码。
 
LSNRCTL> set password
Password:
The command completed successfully
使用set password输入正确的密码后,就可以进行stop操作了。
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值