解决服务器nf_contrack导致丢包问题

问题描述

近日线下测试环境的一个cloudstack计算节点上的虚拟机出现频繁的丢包情况,经过排查日志发现这个计算节点的报文被丢弃,日志信息如下:

Oct 25 10:50:31 hycan-tsp-test-0011 kernel: nf_conntrack: table full, dropping packet
Oct 25 10:50:32 hycan-tsp-test-0011 kernel: nf_conntrack: table full, dropping packet
Oct 25 10:50:33 hycan-tsp-test-0011 kernel: nf_conntrack: table full, dropping packet
Oct 25 10:50:36 hycan-tsp-test-0011 kernel: nf_conntrack: table full, dropping packet
Oct 25 10:50:36 hycan-tsp-test-0011 kernel: nf_conntrack: table full, dropping packet
Oct 25 10:50:37 hycan-tsp-test-0011 kernel: nf_conntrack: table full, dropping packet
Oct 25 10:50:37 hycan-tsp-test-0011 kernel: nf_conntrack: table full, dropping packet
Oct 25 10:50:37 hycan-tsp-test-0011 kernel: nf_conntrack: table full, dropping packet
Oct 25 10:50:38 hycan-tsp-test-0011 kernel: nf_conntrack: table full, dropping packet
Oct 25 10:50:38 hycan-tsp-test-0011 kernel: nf_conntrack: table full, dropping packet
Oct 25 10:50:38 hycan-tsp-test-0011 kernel: nf_conntrack: table full, dropping packet
Oct 25 10:50:39 hycan-tsp-test-0011 kernel: nf_conntrack: table full, dropping packet
Oct 25 10:50:39 hycan-tsp-test-0011 kernel: nf_conntrack: table full, dropping packet
Oct 25 10:50:39 hycan-tsp-test-0011 kernel: nf_conntrack: table full, dropping packet

查询这个错误是因为连接数过高引起的,可以调整nf_conntrack内核参数进行解决。

查看优化相关参数
既然找到了原因,那么我们可以查看并且优化相关参数,默认的net.netfilter.nf_conntrack_max是65536。

sysctl net.netfilter.nf_conntrack_max
net.netfilter.nf_conntrack_max = 131072

那么这个值设置多少合理呢?我在网上找到一个计算公式,以512G内存64位系统为例,计算格式如下:

net.netfilter.nf_conntrack_max = 512*1024*1024*1024/16384/2 = 16777216

优化内核参数。

echo net.netfilter.nf_conntrack_max = 16777216 >> /etc/sysctl.conf
sysctl -p

nf_conntrack还有些相关的参数可以进行优化,这些参数我们在之前已经做过优化了,如下:

net.netfilter.nf_conntrack_tcp_timeout_established = 1800
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值