19c之前的版本,ORACLE数据库的TXT格局listener log不能被主动循环治理(Mos 1744876.1),给使用者造成了很大累赘。

19c开始,导入了一下两个参数:

https://docs.oracle.com/en/database/oracle/oracle-database/19/netrf/oracle-net-listener-parameters-in-listener-ora.html#GUID-FF94A234-A29C-46AA-8770-4CA1BFB5C27C

#### 7.5.3 LOG_FILE_NUM_listener_nameThe LOG_FILE_NUM_listener_name is a diagnostic parameter of the listener.ora file that specifies the number of log file segments.PurposeTo 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.DefaultNo default. If you don't specify a value, or set the value to zero, then the number of segments grows indefinitely.ValuesAny integer value.Example 7-9LOG_FILE_NUM_listener=3#### 7.5.4 LOG_FILE_SIZE_listener_nameThe LOG_FILE_SIZE_listener_name diagnostic parameter of thelistener.ora file specifies the size of each log file segment.PurposeTo specify the size of each log file segment. The size is in MB.Default300 MBValuesAny integer value.Example 7-10 ExampleLOG_FILE_SIZE_listener=10

通过下面的参数,TXT格局的listener log和XML格局的listener log一样能够主动循环治理了。

例:

[oracle@db1903 ~]$ lsnrctl startLSNRCTL for Linux: Version 19.0.0.0.0 - Production on 20-1月 -2021 17:33:16Copyright (c) 1991, 2019, Oracle.  All rights reserved./u01/app/oracle/product/19.3.0/dbhome_1/bin/tnslsnrを起動しています。お待ちください...TNSLSNR for Linux: Version 19.0.0.0.0 - Productionシステム・パラメータ・ファイルは/u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.oraです。ログ・メッセージを/u01/app/oracle/diag/tnslsnr/db1903/listener/alert/log.xmlに書き込みました。リスニングしています: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db1903)(PORT=1521)))リスニングしています: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db1903)(PORT=1521)))に接続中リスナーのステータス------------------------別名                      LISTENERバージョン                TNSLSNR for Linux: Version 19.0.0.0.0 - Production開始日                    20-1月 -2021 17:33:19稼働時間                  0 日 0 時間 0 分 0 秒トレース・レベル          offセキュリティ              ON: Local OS AuthenticationSNMP                      OFFパラメータ・ファイル      /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.oraログ・ファイル            /u01/app/oracle/diag/tnslsnr/db1903/listener/alert/log.xmlリスニング・エンドポイントのサマリー...  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db1903)(PORT=1521)))  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))リスナーはサービスをサポートしていません。コマンドは失常に終了しました。

在/u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.ora文件中设置上面两个参数。

LOG_FILE_NUM_LISTENER=8
LOG_FILE_SIZE_LISTENER=1

重启监听。

[oracle@db1903 ~]$ lsnrctl stop listener[oracle@db1903 ~]$ lsnrctl start listener

测试一下。

$> vi connect.sh#!/bin/bashwhile ( true ); dosqlplus -S -L test/test@localhost:1521/pdb << EOFSELECT * FROM dual;EXIT;EOFdone$> chmod +x connect.sh$> ./connect.sh > /dev/null$> ./connect.sh > /dev/null$> ./connect.sh > /dev/null$> ...

◆TXT格局listener log

[oracle@db1903 trace]$ pwd/u01/app/oracle/diag/tnslsnr/db1903/listener/trace[oracle@db1903 trace]$ ll合計 720-rw-r-----. 1 oracle oinstall  12251  1月 20 17:59 listener.log-rw-r-----. 1 oracle oinstall 482866  1月 20 17:59 listener_1.log

◆XML格局listener log

[oracle@db1903 alert]$ pwd/u01/app/oracle/diag/tnslsnr/db1903/listener/alert[oracle@db1903 alert]$ ll合計 1416-rw-r-----. 1 oracle oinstall     962  1月 20 17:59 log.xml-rw-r-----. 1 oracle oinstall 1048912  1月 20 17:59 log_1.xml

请留神下面的XML格局listener log的大小是1MB,TXT格局listener log却小于1MB。起因是两种格局的Log文件须要记录雷同的接续记录,而每一条TXT格局的接续记录比XML格局应用的空间要小。