`
sjk2013
  • 浏览: 2184949 次
文章分类
社区版块
存档分类
最新评论

Orace 11g 监听 配置修改 说明

 
阅读更多


在之前的Blog中有三篇文章提到了Oracle的监听,如下:

OracleListener 动态注册 与 静态注册

http://blog.csdn.net/tianlesoftware/article/details/5543166

Oracle 监听(Listener) 中 services 说明

http://blog.csdn.net/tianlesoftware/article/details/6617827

Oracle 数据库监听配置

http://blog.csdn.net/tianlesoftware/article/details/4861572

Oracle的监听(Listener)在缺省情况下,会在文件中记录日志,记录数据库实例注册操作、客户端的连接等。

Oracle 11g中的信息如下:

[oracle@dave ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Productionon 22-DEC-2012 21:36:43

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:31:53

Uptime 0 days 0 hr. 4 min. 50 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...

The command completed successfully

这个是Oracle 11g里的listener 的保存位置。在Oracle 11g中使用的是ADR,关于ADR 参考:

Oracle 11g 新特性 -- 自动诊断资料档案库(ADR) 说明

http://blog.csdn.net/tianlesoftware/article/details/8222724

这里是个xml文件,不方便文件,我们可以去trace目录下,看文本格式的:

[oracle@dave trace]$ pwd

/u01/app/oracle/diag/tnslsnr/dave/listener/trace

[oracle@dave trace]$ ls

listener.log

[oracle@dave trace]$

[oracle@dave trace]$ tail -20 listener.log

Sat Dec 22 21:33:39 2012

22-DEC-2012 21:33:39 * service_update *dave * 0

22-DEC-2012 21:33:42 * service_update *dave * 0

22-DEC-2012 21:33:45 * service_update *dave * 0

Sat Dec 22 21:34:18 2012

22-DEC-2012 21:34:18 * service_update *dave * 0

22-DEC-2012 21:34:21 * service_update *dave * 0

22-DEC-2012 21:34:24 * service_update *dave * 0

22-DEC-2012 21:34:27 * service_update *dave * 0

Sat Dec 22 21:34:48 2012

22-DEC-2012 21:34:48 * service_update *dave * 0

Sat Dec 22 21:35:06 2012

22-DEC-2012 21:35:06 * service_update *dave * 0

Sat Dec 22 21:36:18 2012

22-DEC-2012 21:36:18 * service_update *dave * 0

Sat Dec 22 21:36:43 2012

WARNING: Subscription for node down eventstill pending

22-DEC-2012 21:36:43 *(CONNECT_DATA=(CID=(PROGRAM=)(HOST=dave)(USER=oracle))(COMMAND=status)(ARGUMENTS=64)(SERVICE=LISTENER)(VERSION=186647296))* status * 0

Sat Dec 22 21:37:34 2012

22-DEC-2012 21:37:34 * service_update *dave * 0

对于一些使用短连接的,频繁的连接数据库的应用,listener.log增长很快。有的可以在比较短的时间内(十几天)就可以超过2GB。对于一些平台的某些版本的Oracle,在监听日志增大到2GB以后会导致监听不能正常工作。

对于这种listener.log增长非常迅速的系统,可以关闭监听日志,不让监听写日志到文件。也可以写个job定期清理。

关于Oracle Listener 的说明,官网有更多详细描述。

Listener Control Utility

http://docs.oracle.com/cd/E11882_01/network.112/e10835/lsnrctl.htm#NETRF118

这里我们看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 tothelistener.orafile. Any changes are stored inlistener.ora,preserving formatting, comments, and case as much as possible. Beforemodification of thelistener.orafile, a backup of the file,calledlistener.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操作了。

---------------------------------------------------------------------------------------

版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!

Skype: tianlesoftware

QQ: tianlesoftware@gmail.com

Email: tianlesoftware@gmail.com

Blog: http://blog.csdn.net/tianlesoftware

Weibo: http://weibo.com/tianlesoftware

Twitter: http://twitter.com/tianlesoftware

Facebook: http://www.facebook.com/tianlesoftware

Linkedin: http://cn.linkedin.com/in/tianlesoftware


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics