首页 » Cloud, ORACLE 9i-23ai » Oracle 19c新特性: Listener自动清理(Network Log File Segmentation)

Oracle 19c新特性: Listener自动清理(Network Log File Segmentation)

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参数

打赏

对不起,这篇文章暂时关闭评论。