在Oracle的各种日志中,监听日志算是比较大的,尤其是在windows平台,还存在监听日志过大导致监听异常的bug。 所以除了写脚本定期删日志文件之外,就是永久性的把监听写日志的功能关闭。 实际上,在windows 平台要上删日志还需要先停监听,否则会提示文件正在被使用无法删除。 https://www.cndba.cn/dave/article/2828
https://www.cndba.cn/dave/article/2828
https://www.cndba.cn/dave/article/2828
下面看永久的关闭监听日志的方法:
查看监听状态:https://www.cndba.cn/dave/article/2828https://www.cndba.cn/dave/article/2828
[dave@www.cndba.cn ~]$ lsnrctl status
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 01-JUN-2018 09:03:02
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=web)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 01-JUN-2018 09:02:58
Uptime 0 days 0 hr. 0 min. 3 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.1.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/web/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=web)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
[dave@www.cndba.cn ~]$
[dave@www.cndba.cn trace]$ pwd
/u01/app/oracle/diag/tnslsnr/web/listener/trace
[dave@www.cndba.cn trace]$ ll -lh
总用量 66M
-rw-r----- 1 oracle oinstall 13M 6月 1 09:03 listener.log
-rw-r----- 1 oracle oinstall 42M 2月 12 09:31 ora_14017_139945876631872.trc
-rw-r----- 1 oracle oinstall 11M 2月 12 09:31 ora_14017_139945876631872.trm
[dave@www.cndba.cn trace]$
[dave@www.cndba.cn trace]$ rm -rf *
停止监听服务进程(tnslsnr)记录日志。
[dave@www.cndba.cn trace]$ lsnrctl set log_status off;
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 01-JUN-2018 09:04:50
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=web)(PORT=1521)))
LISTENER parameter "log_status" set to OFF
The command completed successfully
[dave@www.cndba.cn trace]$
再次查看监听状态,就没有日志文件的信息了:https://www.cndba.cn/dave/article/2828
[dave@www.cndba.cn trace]$ lsnrctl status
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 01-JUN-2018 09:05:24
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=web)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 01-JUN-2018 09:02:58
Uptime 0 days 0 hr. 2 min. 26 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.1.0/db_1/network/admin/listener.ora
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=web)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
[dave@www.cndba.cn trace]$
但是这种修改只对当前的环境有效,一旦监听重启后又会重新生成日志,所以我们需要把修改写入到监听的配置文件中去:
[dave@www.cndba.cn trace]$ lsnrctl set log_status off;
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 01-JUN-2018 09:07:04
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=web)(PORT=1521)))
LISTENER parameter "log_status" set to OFF
The command completed successfully
保存配置信息https://www.cndba.cn/dave/article/2828
[dave@www.cndba.cn trace]$ lsnrctl save_config
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 01-JUN-2018 09:07:21
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=web)(PORT=1521)))
Saved LISTENER configuration parameters.
Listener Parameter File /u01/app/oracle/product/12.1.0/db_1/network/admin/listener.ora
Old Parameter File /u01/app/oracle/product/12.1.0/db_1/network/admin/listener.bak
The command completed successfully
[dave@www.cndba.cn trace]$
这样修改之后,在监听的配置文件中就会多一条配置:LOGGING_LISTENER = OFFhttps://www.cndba.cn/dave/article/2828https://www.cndba.cn/dave/article/2828
[dave@www.cndba.cn admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/12.1.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = web)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
#----ADDED BY TNSLSNR 01-JUN-2018 09:07:21---
LOGGING_LISTENER = OFF
#--------------------------------------------
[dave@www.cndba.cn admin]$
当然也可以直接在listener.ora文件增加上面的内容来关闭监听日志。但是只有在监听重启后才会生效,而通过lsnrctl 这个命令接口,可以立即生效,Windows平台上的文件会立即关闭。因此可以利用这个特性,用来删除WINDOWS平台上的监听日志文件,因为不这样,在监听运行时监听日志是不能删除的。https://www.cndba.cn/dave/article/2828
版权声明:本文为博主原创文章,未经博主允许不得转载。