温馨提示×

如何减少centos dropped

小樊
40
2026-10-12 00:37:18
栏目: 智能运维

在 CentOS(及其他 Linux 系统)中,dropped 通常指网络丢包(RX/TX dropped),常见于 ifconfig、ip -s link、sar -n DEV 或 netstat -i 的输出中。下面按常见原因 → 排查方法 → 解决措施来说明如何减少 CentOS 的 dropped。


一、先确认 dropped 在哪里

ip -s link

或

ifconfig

或

ethtool -S eth0 | grep drop

重点关注:

  • RX dropped
  • TX dropped

二、常见原因及对应优化方案

1️⃣ 网卡接收队列溢出(最常见)

现象:RX dropped 持续增加
原因:

  • 中断处理不过来
  • 队列太小
  • CPU 软中断瓶颈

✅ 解决方案:

# 查看队列长度
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

2️⃣ 连接跟踪(conntrack)表满

现象:高并发时出现 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

3️⃣ 系统文件描述符不足

现象:大量连接时 dropped
✅ 调整:

ulimit -n 1000000

永久:

cat >> /etc/security/limits.conf <<EOF
* soft nofile 1000000
* hard nofile 1000000
EOF

4️⃣ 网络栈缓冲区太小

✅ 调整 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

5️⃣ 网卡 offload 异常

有时网卡 offload 会导致 dropped:

ethtool -k eth0

可尝试关闭(性能可能略降):

ethtool -K eth0 gro off
ethtool -K eth0 lro off

6️⃣ 防火墙 / 安全策略丢包

✅ 检查:

dmesg | grep drop
journalctl -k | grep drop

✅ 确认:

  • iptables / nftables 规则
  • fail2ban
  • SELinux(临时关闭测试)

7️⃣ 物理 / 交换机问题

  • 网线 / 光模块故障
  • 交换机端口限速
  • 双工模式不匹配
ethtool eth0

确保:

Speed: 1000Mb/s
Duplex: Full

三、快速排查 checklist

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 输出
  • 网卡型号
  • CentOS 版本

我可以帮你精准定位 dropped 原因。

0 踩