19c以前的监听日志(listener log)无论是txt还是xml格式的文件都要手动清理,XML的文件是10M一个切换,但是txt格式的(listener.log)是持续增长,导致文件系统full或监听性能问题,多年前整理过一篇自动清理监听日志的Shell: To delete listener log file contains text and xml format (自动清理监听日志) 在我们的生产环境oracle 11g\12c on AIX\HPUX\LINUX都运行多年良好。
也可以使用以下shell 监控日志文件大小:
[oracle@oel7db1 ~]$ for i in `echo "show tracefile %.log"|adrci|grep tns`
> do
> ls -ltr $ORACLE_BASE/$i|awk -F" " '{print "file: "$9" Size: "$5}'
> done
file: /u01/app/oracle/diag/tnslsnr/oel7db1/listener/trace/listener.log Size: 215450
在 Oracle 19c 上,Oracle 引入了两个有关listener管理的新参数。我们可以在Oracle内配置日志轮换,而无需在OS shell 脚本上进行任何额外配置,实现logrotate功能。该特性叫做“Oracle Network Log File Segmentation”
Oracle Network Log File Segmentation
The maximum size and number of text log files can be configured for Oracle Network components such as Oracle Net Listener, Oracle Connection Manager, and Global Service Manager. This feature allows better management of log files, particularly in Cloud environments.
Use below parameters to define number of files with defined size
LOG_FILE_NUM_listener_name
To specify the number of log file segments. At any point of time there can be only “n” log file segments where “n” is LOG_FILE_NUM_listener_name.
If the log grows beyond this number, then the older segments are deleted.
**LOG_FILE_SIZE_listener_name**
To specify the size of each log file segment. The size is in MB.
举例说明
[oracle@oel7db1 ~]$ cat /u01/app/oracle/product/19.2.0/db_1/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/19.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oel7db1)(PORT = 1521)(IP=FIRST))
(ADDRESS = (PROTOCOL = TCP)(HOST = oel7db1)(PORT = 1521)(IP=V4_ONLY))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
USE_SID_AS_SERVICE_LISTENER=on
LOG_FILE_NUM_LISTENER=10
LOG_FILE_SIZE_LISTENER=100
[oracle@oel7db1 ~]$ lsnrctl stop
[oracle@oel7db1 ~]$ lsnrctl start
重启生效。
另外还有2个NO-ADR参数
TRACE_FILEAGE_listener_name: Specifies the maximum age of listener trace file in minutes. (Default: Unlimited).
TRACE_FILELEN_listener: Specifies size the maximum listener trace file size in KB (Default: Unlimited).
最后修改时间:2021-08-11 10:09:31
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




