【LISTENER】禁止產生監聽器日誌的方法

壹頁書發表於2015-10-14
  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 --

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29254281/viewspace-1814072/,如需轉載,請註明出處,否則將追究法律責任。

相關文章