Oracle 如何关闭监听日志
Oct132016
前段时间,一套小型生产数据库,由于使用很多短连接,并且连接相当频繁,监听日志文件占用了大量的磁盘空间。检查日志内容,发现都是正常的连接,那么在不需要分析监听日志的情况下,可以直接关闭监听的日志输出,如果在需要通过监听日志来分析故障或解决问题时,再打开监听日志的输出。
以下是默认情况下,监听的状态信息,以下信息来自测试数据库。
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SL010A-IVADT2)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production Start Date 26-MAY-2016 10:40:47 Uptime 102 days 23 hr. 13 min. 28 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/SL010A-IVADT2/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=SL010A-IVADT2)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Services Summary... Service "ivldb" has 1 instance(s). Instance "ivldb", status READY, has 1 handler(s) for this service... Service "ivldbXDB" has 1 instance(s). Instance "ivldb", status READY, has 1 handler(s) for this service... Service "ivlifdb" has 1 instance(s). Instance "ivlifdb", status READY, has 1 handler(s) for this service... Service "ivlifdbXDB" has 1 instance(s). Instance "ivlifdb", status READY, has 1 handler(s) for this service... The command completed successfully
监听日志受log_status参数控制,ON为开打,这也是默认值,OFF为关闭。可以通过LSNRCTL工具的show命令来查看参数的状态。
[oracle@SL010A-IVADT2 ~]$ lsnrctl LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 06-SEP-2016 10:08:15 Copyright (c) 1991, 2013, Oracle. All rights reserved. Welcome to LSNRCTL, type "help" for information. LSNRCTL> show log_status Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SL010A-IVADT2)(PORT=1521))) LISTENER parameter "log_status" set to ON The command completed successfully
当前log_status参数为开启状态,通过set命令将之关闭。
LSNRCTL> set log_status off Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SL010A-IVADT2)(PORT=1521))) LISTENER parameter "log_status" set to OFF The command completed successfully
此时再次查询监听状态将会发现Listener Log File这行将不在显示。
LSNRCTL> status Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SL010A-IVADT2)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production Start Date 26-MAY-2016 10:40:47 Uptime 102 days 23 hr. 27 min. 37 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=SL010A-IVADT2)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Services Summary... Service "ivldb" has 1 instance(s). Instance "ivldb", status READY, has 1 handler(s) for this service... Service "ivldbXDB" has 1 instance(s). Instance "ivldb", status READY, has 1 handler(s) for this service... Service "ivlifdb" has 1 instance(s). Instance "ivlifdb", status READY, has 1 handler(s) for this service... Service "ivlifdbXDB" has 1 instance(s). Instance "ivlifdb", status READY, has 1 handler(s) for this service... The command completed successfully
此时,再有新的连接,将不会记录到监听日志文件。