温馨提示×

centos message为何突然增多

小樊
42
2026-10-11 22:44:14
栏目: 智能运维

在 CentOS 系统中,/var/log/messages(或 journalctl 中的 message 日志)突然增多,通常不是单一原因,而是以下几类情况之一。可以按“先定位、再定性、后处理”的思路排查。


一、先确认「增多的到底是什么」

1. 看最近日志内容

tail -n 100 /var/log/messages
# 或(CentOS 7+)
journalctl -p err -n 100

常见突然增多的日志类型:

  • 内核日志(kernel)
  • 网络相关(eth / firewall / ssh)
  • 服务异常重启(systemd)
  • 磁盘 / 文件系统
  • 硬件问题(CPU、内存、磁盘)

二、常见原因及对应特征

1️⃣ 网络问题(最常见)

特征:

kernel: TCP: time wait bucket table overflow
ssh: Failed password for root
eth0: link down / link up

可能原因:

  • 被扫描 / 暴力破解(SSH、Redis、MySQL)
  • 网络抖动、网卡频繁 up/down
  • 防火墙规则变化

✅ 检查:

lastb
ss -ntup
firewall-cmd --list-all

2️⃣ 服务频繁重启

特征:

systemd: xxx.service: Main process exited
systemd: xxx.service: Failed with result 'exit-code'

可能原因:

  • 程序 bug
  • 配置错误
  • OOM 被 kill

✅ 检查:

systemctl status xxx
journalctl -u xxx -n 50

3️⃣ 磁盘 / 文件系统问题

特征:

kernel: EXT4-fs error
I/O error
read-only file system

可能原因:

  • 磁盘坏道
  • RAID 降级
  • 空间满导致写入失败

✅ 检查:

df -h
dmesg | grep error
smartctl -a /dev/sda

4️⃣ 内存不足(OOM)

特征:

Out of memory: Kill process

✅ 检查:

dmesg | grep -i oom
free -m

5️⃣ 日志级别被改低

特征:

  • 平时没日志,突然全是 info/debug
  • 系统没异常,但量很大

✅ 检查:

  • /etc/rsyslog.conf
  • 服务自身日志级别

6️⃣ 时间跳变(NTP)

特征:

systemd: Time has been changed

✅ 检查:

timedatectl

三、快速定位脚本(推荐)

# 看哪个程序写日志最多
journalctl --since "1 hour ago" | awk '{print $5}' | sort | uniq -c | sort -nr | head

四、你可以这样告诉我,我帮你精准判断

请把以下信息发我:

  1. CentOS 版本(cat /etc/redhat-release)
  2. 日志示例(10–20 行)
  3. 是 /var/log/messages 还是 journalctl
  4. 是否伴随性能下降 / 服务异常

我可以直接帮你判断是攻击、故障,还是正常波动。

0 踩