温馨提示×

centos dropped怎么定位

小樊
46
2026-07-20 19:33:21
栏目: 智能运维

“centos dropped” 通常指 CentOS 系统里出现丢包(packet drop)或连接被丢弃 的现象,可能是网络、内核、硬件或应用层问题。下面给你一套定位思路 + 常用命令,按从浅到深来排查。


一、先明确“dropped”出现在哪一层

不同地方含义不同:

场景 含义
ifconfig / ip -s link 网卡层丢包
netstat -s 协议栈丢包
ss -s socket 缓冲区丢包
dmesg 内核/驱动丢包
应用日志 应用层拒绝或超时

二、网卡层丢包(最常见)

1️⃣ 查看网卡统计

ip -s link

ifconfig -a

重点看:

  • RX dropped
  • TX dropped
  • errors
  • overruns

RX dropped:接收丢包
TX dropped:发送丢包


2️⃣ 查看网卡队列(ring buffer)

ethtool -S eth0

(把 eth0 换成你的网卡)

重点看:

  • rx_queue_*_drops
  • rx_dropped
  • tx_dropped

3️⃣ 查看 ring buffer 是否太小

ethtool -g eth0

如果 rx 很小(如 256),可以调大:

ethtool -G eth0 rx 4096
ethtool -G eth0 tx 4096

⚠️ 重启失效,需写入配置文件或启动脚本。


三、协议栈 / 内核丢包

4️⃣ 查看协议层统计

netstat -s

重点看:

  • packet receive errors
  • segments dropped
  • listen queue overflow
  • TCPBacklogDrop

5️⃣ socket 缓冲区满

ss -s

如果 recv-q / send-q 很大,说明:

  • 应用处理不过来
  • socket buffer 太小

查看当前 buffer:

sysctl net.core.rmem_max
sysctl net.core.wmem_max

临时调大:

sysctl -w net.core.rmem_max=16777216
sysctl -w net.core.wmem_max=16777216

四、连接被丢弃(listen overflow)

6️⃣ 半连接 / 全连接队列满

netstat -s | grep -i listen

ss -ltn

Recv-Q 是否接近 backlog

调大 backlog:

sysctl -w net.core.somaxconn=4096

应用层也要配合(如 nginx backlog、java SO_BACKLOG)。


五、防火墙 / 策略丢包

7️⃣ iptables / firewalld

iptables -nvL

firewall-cmd --list-all

查看是否有:

  • DROP 规则
  • 限速规则

六、内核 / 驱动 / 硬件问题

8️⃣ 查看内核日志

dmesg | egrep -i "drop|error|eth|oom"

常见问题:

  • 网卡驱动 bug
  • 内存不足(OOM)
  • 中断不均衡

9️⃣ 中断不均(高并发场景)

cat /proc/interrupts

如果某个 CPU 中断很高:

irqbalance

或手动绑定中断。


七、应用层“dropped”

10️⃣ 应用日志

  • Nginx:error.log
  • 数据库:连接数、超时
  • Java:线程池满、GC

八、快速定位 checklist(实用)

✅ 网卡丢包?

ip -s link

✅ 协议栈丢包?

netstat -s

✅ 队列满?

ss -ltn

✅ 内核问题?

dmesg

✅ CPU / 内存?

top
free -h

九、如果你愿意,我可以进一步帮你

你可以直接贴出:

  • ip -s link
  • netstat -s
  • dmesg | tail -50
  • 出现 dropped 的具体场景(SSH、HTTP、DB、压测?)

我可以直接帮你判断是哪一层丢包,以及怎么改

0