转载

【LISTENER】禁止产生监听器日志的方法

  Oracle默认配置情况下,会不停的生成监听器的日志,类似于数据库的alert日志。监听器的日志默认保存在$ORACLE_HOME/network/log/listener.log文件中,记录了监听器提供服务的状态信息。如果监听器的日志一直处于无人管理的状态下,很有可能遭遇由于监听器日志文件过大导致系统空间不足的问题。

  如果确认不需要监听器日志来辅助问题排查,可以考虑禁止生成监听器日志。主要有两种实现方法,一种方法是在不需要重启监听器的情况下通过设置log_status参数为off来实现;另外一种方法是在listener.ora文件中增加LOGGING_=OFF参数,然后重启监听器实现。

1.查看监听器状态信息
secdb@secdb /home/oracle$ lsnrctl

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 30-AUG-2011 21:19:46

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

Welcome to LSNRCTL, type "help" for information.

LSNRCTL> status
Connecting to (DESCRIPTION=(address=(protocol=tcp)(host=secdb)(port=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                30-AUG-2011 13:01:18
Uptime                    0 days 8 hr. 18 min. 29 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/ora10gR2/product/10.2.0/db_2/network/admin/listener.ora
Listener Log File         /oracle/ora10gR2/product/10.2.0/db_2/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=secdb.localdomain)(PORT=1521)))
Services Summary...
Service "ora10g" has 1 instance(s).
  Instance "ora10g", status READY, has 1 handler(s) for this service...
The command completed successfully


监听信息中记录了Listener Log File相关信息。

2.通过设置log_status参数为off实现禁止生成监听器日志
1)查看log_status参数内容
LSNRCTL> show log_status
Connecting to (DESCRIPTION=(address=(protocol=tcp)(host=secdb)(port=1521)))
LISTENER parameter "log_status" set to ON
The command completed successfully


默认情况下log_status参数是on的状态,表示生成监听器日志信息。

2)通过调整log_status参数值为off禁止生成监听日志
LSNRCTL> set log_status off
Connecting to (DESCRIPTION=(address=(protocol=tcp)(host=secdb)(port=1521)))
LISTENER parameter "log_status" set to OFF
The command completed successfully


3)查看调整结果
LSNRCTL> status
Connecting to (DESCRIPTION=(address=(protocol=tcp)(host=secdb)(port=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                30-AUG-2011 13:01:18
Uptime                    0 days 8 hr. 19 min. 52 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/ora10gR2/product/10.2.0/db_2/network/admin/listener.ora
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=secdb.localdomain)(PORT=1521)))
Services Summary...
Service "ora10g" has 1 instance(s).
  Instance "ora10g", status READY, has 1 handler(s) for this service...
The command completed successfully


此时监听日志对应的信息已经不在。

3.设置LOGGING_=OFF参数实现禁止生成监听器日志
1)启用监听日志写出
使用“set log_status on”命令启用监听日志功能
LSNRCTL> set log_status on
Connecting to (DESCRIPTION=(address=(protocol=tcp)(host=secdb)(port=1521)))
LISTENER parameter "log_status" set to ON
The command completed successfully


2)查看监听状态
LSNRCTL> status
Connecting to (DESCRIPTION=(address=(protocol=tcp)(host=secdb)(port=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                30-AUG-2011 13:01:18
Uptime                    0 days 8 hr. 21 min. 12 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/ora10gR2/product/10.2.0/db_2/network/admin/listener.ora
Listener Log File         /oracle/ora10gR2/product/10.2.0/db_2/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=secdb.localdomain)(PORT=1521)))
Services Summary...
Service "ora10g" has 1 instance(s).
  Instance "ora10g", status READY, has 1 handler(s) for this service...
The command completed successfully


3)在listener.ora文件中增加“LOGGING_LISTENER=OFF”
secdb@secdb /home/oracle$ cd $ORACLE_HOME/network/admin
secdb@secdb /oracle/ora10gR2/product/10.2.0/db_2/network/admin$ vi listener.ora
listener=
  (description=
    (address=(protocol=tcp)(host=secdb)(port=1521)))

LOGGING_LISTENER=OFF
~
~

4)停启监听器使参数调整生效
secdb@secdb /oracle/ora10gR2/product/10.2.0/db_2/network/admin$ lsnrctl

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 30-AUG-2011 21:31:50

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

Welcome to LSNRCTL, type "help" for information.


LSNRCTL> stop
Connecting to (DESCRIPTION=(address=(protocol=tcp)(host=secdb)(port=1521)))
The command completed successfully

LSNRCTL> start
Starting /oracle/ora10gR2/product/10.2.0/db_2/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /oracle/ora10gR2/product/10.2.0/db_2/network/admin/listener.ora
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=secdb.localdomain)(PORT=1521)))

Connecting to (DESCRIPTION=(address=(protocol=tcp)(host=secdb)(port=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                30-AUG-2011 21:32:01
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/ora10gR2/product/10.2.0/db_2/network/admin/listener.ora
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=secdb.localdomain)(PORT=1521)))
The listener supports no services
The command completed successfully
LSNRCTL>


调整完毕,此时监听器状态中已经不存在有关监听器日志信息。监听器日志写出已被禁用。

4.小结
  本文给出了两种禁止生成监听日志的方法,一种方法是在不需要重启监听器的情况下通过设置log_status参数为off来实现,另外一种方法是在listener.ora文件中增加LOGGING_=OFF参数,然后重启监听器实现。根据实际影响范围做好取舍。
  另外,监听日志中记录了大量有关监听器的使用信息,是否禁止产生监听日志请谨慎抉择。

Good luck.

secooler
11.08.30

-- The End --

正文到此结束
Loading...