在 CentOS(及其他 Linux 系统)中,dropped 通常指网络丢包(RX/TX dropped),常见于 ifconfig、ip -s link、sar -n DEV 或 netstat -i 的输出中。下面按常见原因 → 排查方法 → 解决措施来说明如何减少 CentOS 的 dropped。
ip -s link
或
ifconfig
或
ethtool -S eth0 | grep drop
重点关注:
RX droppedTX dropped现象:RX dropped 持续增加
原因:
✅ 解决方案:
# 查看队列长度
ethtool -g eth0
# 增大 RX/TX 队列
ethtool -G eth0 rx 4096 tx 4096
✅ 开启多队列 + IRQ 均衡:
# 查看队列数
ethtool -l eth0
# 开启
ethtool -L eth0 combined 8
✅ 绑定中断到 CPU(避免单核瓶颈):
# 安装
yum install irqbalance
systemctl enable irqbalance
systemctl start irqbalance
现象:高并发时出现 dropped
日志:
nf_conntrack: table full, dropping packet
✅ 调整 conntrack:
sysctl -w net.netfilter.nf_conntrack_max=1048576
sysctl -w net.netfilter.nf_conntrack_tcp_timeout_established=3600
持久化:
cat >> /etc/sysctl.conf <<EOF
net.netfilter.nf_conntrack_max = 1048576
net.netfilter.nf_conntrack_tcp_timeout_established = 3600
EOF
sysctl -p
现象:大量连接时 dropped
✅ 调整:
ulimit -n 1000000
永久:
cat >> /etc/security/limits.conf <<EOF
* soft nofile 1000000
* hard nofile 1000000
EOF
✅ 调整 TCP / 网络缓冲:
cat >> /etc/sysctl.conf <<EOF
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.core.netdev_max_backlog = 10000
EOF
sysctl -p
有时网卡 offload 会导致 dropped:
ethtool -k eth0
可尝试关闭(性能可能略降):
ethtool -K eth0 gro off
ethtool -K eth0 lro off
✅ 检查:
dmesg | grep drop
journalctl -k | grep drop
✅ 确认:
ethtool eth0
确保:
Speed: 1000Mb/s
Duplex: Full
ip -s link
ethtool -S eth0 | grep -i drop
dmesg | grep drop
sysctl net.netfilter.nf_conntrack_max
ethtool -g eth0
top (看软中断 %si)
| 场景 | 建议 |
|---|---|
| 高并发 Web | 增大 netdev backlog + conntrack |
| 视频 / 大流量 | 增大 RX/TX 队列 |
| 容器环境 | 检查 veth / bridge |
| 云服务器 | 多为宿主机限制 |
如果你愿意,可以贴出:
ip -s link 输出我可以帮你精准定位 dropped 原因。