手工清理监听日志

时间:2023-01-26 19:49:21

oracle 监听日志配置文件,大于4G,不在增加,因此需要手工清理。

单实例环境下监听日志存储在Oracle目录下,RAC环境下监听日志存储在Grid用户下。

本次使用Oracle单实例测试清理,本质情况相同(RAC使用Grid用户操作,情况相同)

[ora122@enmodb1 ~]$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 08-MAR-2019 09:38:06

Copyright (c) 1991, 2016, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                04-MAR-2019 18:43:31
Uptime                    3 days 14 hr. 54 min. 34 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/ora122/product/12.2.0.1/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/ora122/diag/tnslsnr/enmodb1/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=enmodb1)(PORT=1522)))

[ora122@enmodb1 ~]$ lsnrctl

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 08-MAR-2019 09:38:11

Copyright (c) 1991, 2016, Oracle. All rights reserved.

Welcome to LSNRCTL, type "help" for information.

LSNRCTL> show log
Ambiguous text "log", valid completions are:

log_file log_directory log_status

LSNRCTL> show log_status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1522)))
LISTENER parameter "log_status" set to ON
The command completed successfully
LSNRCTL>
LSNRCTL> set log_status off
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1522)))
LISTENER parameter "log_status" set to OFF
The command completed successfully
LSNRCTL> exit

 

#查询监听状态
Listener Log File         /u01/app/ora122/diag/tnslsnr/enmodb1/listener/alert/log.xml
在alert同级别trace目录下
cd /u01/app/ora122/diag/tnslsnr/enmodb1/listener/trace

[ora122@enmodb1 trace]$ du -sm listener.log
2 listener.log
[ora122@enmodb1 trace]$ mv listener.log listener.log_20190308.log

 

 

[ora122@enmodb1 trace]$ lsnrctl

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 08-MAR-2019 09:39:21

Copyright (c) 1991, 2016, Oracle. All rights reserved.

Welcome to LSNRCTL, type "help" for information.

LSNRCTL> show log
Ambiguous text "log", valid completions are:

log_file log_directory log_status

LSNRCTL> set log_status on
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1522)))
LISTENER parameter "log_status" set to ON
The command completed successfully
LSNRCTL> exit

有新的日志输出即可。

[ora122@enmodb1 trace]$ tail -f listener.log