11g监听日志清理

本文讲述了在Oracle11g环境下,由于监听日志文件过大导致数据库连接问题的解决过程,包括定位监听日志位置、清理过期日志以及备份操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

通过监听登陆数据库,都会向监听日志文件写日志,并且使用动态监听,pmon进程会将动态注册的信息写到监听日志文件中去。

日志文件达到4G,部分OS达到4G后,不会向监听日志文件写新的内容,故需要清理。

背景前提:客户反映数据库连接有卡顿,程序无法连接

原因分析:11g监听发生变化

解决

1.查找监听日志的位置

执行代码!lnsrctl status

#核心代码
Listener Parameter File   /u01/app/oracle/product/19.3.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml 
#注意,这是一个【告警日志】,在11g版本中,内存达到11M时候会自动切换日志,所以它永远不会满

❗ 即可通过以下代码直接找到监听日志的位置

[oracle@localhost ~]$ find $ORACLE_BASE -name listener

真正的监听日志位置为/u01/app/oracle/diag/tnslsnr/localhost/listener

[oracle@localhost ~]$cd /u01/app/oracle/diag/tnslsnr/localhost/listener
[oracle@localhost listener]$

在listener中ll显示文件

[oracle@localhost listener]$ ll
total 8
drwxr-x---. 2 oracle oinstall   21 Oct  5 18:50 alert
drwxr-x---. 2 oracle oinstall    6 Oct  5 18:50 cdump
drwxr-x---. 2 oracle oinstall    6 Oct  5 18:50 incident
drwxr-x---. 2 oracle oinstall    6 Oct  5 18:50 incpkg
drwxr-x---. 2 oracle oinstall 4096 Oct  5 18:50 lck
drwxr-x---. 5 oracle oinstall   48 Oct  5 18:50 log
drwxr-x---. 2 oracle oinstall 4096 Oct  5 18:50 metadata
drwxr-x---. 2 oracle oinstall    6 Oct  5 18:50 metadata_dgif
drwxr-x---. 2 oracle oinstall    6 Oct  5 18:50 metadata_pv
drwxr-x---. 2 oracle oinstall    6 Oct  5 18:50 stage
drwxr-x---. 2 oracle oinstall    6 Oct  5 18:50 sweep
drwxr-x---. 2 oracle oinstall   26 Oct  5 18:50 trace

进入trace目录

[oracle@localhost listener]$ cd trace
[oracle@localhost trace]$ ll
total 12
-rw-r-----. 1 oracle oinstall 12254 Oct  6 01:26 listener.log
# 这才是真正的监听日志位置(达到4G过后会出现故障)
2.清理监听日志文件

登录到监听的界面

[oracle@localhost trace]$ lsnrctl

查看监听日志

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
remote_registration_address

查看log_status日志状态

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

显示转态为ON,所以需要将其关闭

LSNRCTL>set log_status off

进入trace目录中清理日志(实验操作建议备份)

[oracle@localhost trace]$ mv lsnrctl.log    lsnrctl.log .bak

打开记录日志

LSNRCTL>set log_status on

重新加载监听

LSNRCTL>reload

3.记得备份日志
[oracle@localhost trace]$ll
-rw-r-----. 1 oracle oinstall 12560 Oct  6 01:46 listener.log
-rw-r-----. 1 oracle oinstall 12560 Oct  6 01:46 listener.log.bak
[oracle@localhost trace]$tar czvf listener.log.bak.gz listener.log.bak

                
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值