oracle监听日志文件过大

2024年 6月 30日 70.9k 0

一、背景

oracle监听日志文件大小达到4G,不会往监听日志文件中写入新的日志,此时就要对监听日志进行清除。

二、清除监听日志

oracle的监听日志目录:
/u01/app/oracle/diag/tnslsnr/node01/listener/trace(node01是主机名)

1.查看监听状态

\[oracle@node01 listener\]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 19-AUG-2021 03:24:09

Copyright © 1991, 2013, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=node01)(PORT=1521)))
STATUS of the LISTENER

Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 18-AUG-2021 17:53:57
Uptime 0 days 9 hr. 30 min. 11 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db\_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/node01/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=node01)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary…
Service “orcl” has 1 instance(s).
Instance “orcl”, status READY, has 1 handler(s) for this service…
Service “orclXDB” has 1 instance(s).
Instance “orcl”, status READY, has 1 handler(s) for this service…
The command completed successfully

监听状态是开启的,需要注意的是监听处于开启状态是不可以修改监听日志文件名或者删除监听日志文件的。

2.清除监听日志的方法

方法一、关闭监听清除监听日志

  • 1.关闭监听

\[oracle@node01 listener\]$ lsnrctl stop

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 19-AUG-2021 03:38:19

Copyright © 1991, 2013, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=node01)(PORT=1521)))

The command completed successfully

  • 2.清除监听日志

\[oracle@node01 trace\]$ rm -rf listener.log

也可以备份监听日志文件,然后再删除原有监听日志文件

\[oracle@node01 trace\]$ mv listener.log listener.log.bak
\[oracle@node01 trace\]$ ll
\-rw-r-----. 1 oracle oinstall 106920 Aug 19 03:24 listener.log.bak

  • 3.重新开启监听

\[oracle@node01 trace\]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 19-AUG-2021 03:41:19

Copyright © 1991, 2013, Oracle. All rights reserved.

Starting /u01/app/oracle/product/11.2.0/db\_1/bin/tnslsnr: please wait…

TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db\_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/node01/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=node01)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=node01)(PORT=1521)))
STATUS of the LISTENER

Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 19-AUG-2021 03:41:19
Uptime 0 days 0 hr. 0 min. 4 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db\_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/node01/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=node01)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
\[oracle@node01 trace\]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 19-AUG-2021 03:41:29

Copyright © 1991, 2013, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=node01)(PORT=1521)))
STATUS of the LISTENER

Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 19-AUG-2021 03:41:19
Uptime 0 days 0 hr. 0 min. 10 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db\_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/node01/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=node01)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary…
Service “orcl” has 1 instance(s).
Instance “orcl”, status READY, has 1 handler(s) for this service…
Service “orclXDB” has 1 instance(s).
Instance “orcl”, status READY, has 1 handler(s) for this service…

The command completed successfully
此时在监听日志目录就会再次生成一个监听日志文件listener.log

方法二、不关闭监听清除监听日志

  • 1.查看当前监听状态

\[oracle@node01 listener\]$ lsnrctl

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 19-AUG-2021 03:24:13

Copyright © 1991, 2013, Oracle. All rights reserved.

Welcome to LSNRCTL, type “help” for information.

LSNRCTL> show
The following operations are available after show
An asterisk (\*) denotes a modifier or extended command:

rawmode displaymode
rules trc\_file
trc\_directory trc\_level
log\_file log\_directory
log\_status current\_listener
inbound\_connect\_timeout startup\_waittime
snmp\_visible save\_config\_on\_stop
dynamic\_registration enable\_global\_dynamic\_endpoint
oracle\_home pid
connection\_rate\_limit valid\_node\_checking\_registration
registration\_invited\_nodes registration\_excluded\_nodes

LSNRCTL> show log\_status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=node01)(PORT=1521)))
LISTENER parameter “log\_status” set to ON

The command completed successfully

  • 2.停止记录监听日志

LSNRCTL> set log\_status off
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=node01)(PORT=1521)))
LISTENER parameter “log\_status” set to OFF

The command completed successfully

  • 3.清除监听日志

\[oracle@node01 trace\]$ rm -rf listener.log

也可以备份监听日志文件,然后再删除原有监听日志文件

\[oracle@node01 trace\]$ mv listener.log listener.log.bak
\[oracle@node01 trace\]$ ll
\-rw-r-----. 1 oracle oinstall 106920 Aug 19 03:24 listener.log.bak

  • 4.开启记录监听日志

LSNRCTL> set log\_status on
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=node01)(PORT=1521)))
LISTENER parameter “log\_status” set to ON

The command completed successfully

  • 5.重新加载监听

LSNRCTL> reload
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=node01)(PORT=1521)))
The command completed successfully

此时在监听日志目录就会再次生成一个监听日志文件listener.log

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论