oracle监听器日志文件(通常叫做listener.log)是一个纯文本文件,它的大小是一直不断增长的,在一个生产oracle服务器上,dba会每日查看该文件,如检查监听器是否有异常停止,是否有恶意攻击连接等,当这个文件特别大的时候,打开和浏览文件内容时可能比较慢。这时可能会想到将当前的日志文件备份一下,然后重新创建一个新的日志文件,但oracle的监听器在运行时是不允许对其日志文件做删除,重命名操作,于是只有停止监听器。重命名后,再启动监听器,启动时会自动创建一个新的监听器日志文件,但这样客户端连接就会断开,下面介绍一种方法在不停止监听器的情况下,重命名监听器日志文件。
lsnrctl set log_status off
lsnrctl set log_status on
注意:集群中listener_scan1.log清理方式有所不同
lsnrctl命令行模式(windows在命令行下操作,linux和aix均同命令)
set current_listener listener_scan1
set log_status off
cat /dev/null > listener_scan1.log
set log_status on
cat listener_scan1.log
单实例处理下
[grid@rac1 trace]$ ls -ltrh
total 1.5g
-rw-r—– 1 grid oinstall 0 feb 1 2018 ora_5167_140127273219808.trc
-rw-r—– 1 grid oinstall 0 apr 7 2018 ora_5347_140710176175840.trc
-rw-r—– 1 grid oinstall 0 dec 3 23:13 ora_5347_140113590142688.trc
-rw-r—– 1 grid oinstall 0 dec 5 08:11 ora_5375_140648166098656.trc
-rw-r—– 1 grid oinstall 1.5g feb 25 16:51 listener_scan1.log
暂停
[grid@rac1 trace]$ lsnrctl set log_status off
lsnrctl for linux: version 11.2.0.3.0 – production on 25-feb-2019 16:52:06
copyright (c) 1991, 2011, oracle. all rights reserved.
connecting to (description=(address=(protocol=ipc)(key=listener)))
listener parameter “log_status” set to off
the command completed successfully
转移
[grid@rac1 trace]$
[grid@rac1 trace]$ mv listener_scan1.log /mnt/tmp
[grid@rac1 trace]$
重建
[grid@rac1 trace]$ lsnrctl set log_status on
lsnrctl for linux: version 11.2.0.3.0 – production on 25-feb-2019 16:54:47
copyright (c) 1991, 2011, oracle. all rights reserved.
connecting to (description=(address=(protocol=ipc)(key=listener)))
listener parameter “log_status” set to on
the command completed successfully
[grid@rac1 trace]$ ls -ltrh
total 4.0k
-rw-r—– 1 grid oinstall 0 feb 1 2018 ora_5167_140127273219808.trc
-rw-r—– 1 grid oinstall 0 apr 7 2018 ora_5347_140710176175840.trc
-rw-r—– 1 grid oinstall 0 dec 3 23:13 ora_5347_140113590142688.trc
-rw-r—– 1 grid oinstall 0 dec 5 08:11 ora_5375_140648166098656.trc
-rw-r—– 1 grid oinstall 188 feb 25 16:55 listener_scan1.log