如何正确配置 net.ipv4.neigh.default.gc_thresh_n

如何正确配置 net.ipv4.neigh.default.gc_thresh_n

kernel: neighbour: arp_cache: neighbor table overflow!我们的 kubernetes 集群的某些节点最近出现了大量错误。

经过研究,我们发现我们需要增加服务器net.ipv4.neigh.default.gc_thresh{1,2,3}以满足最近添加到我们的集群的一些新应用程序的需求。

在进行一些研究时,我无法找到任何合适的方法来计算最适合放置在那里的值。

如何确定应该在那里设置什么?

答案1

让我们看看文档

neigh/default/gc_thresh1 - INTEGER
    Minimum number of entries to keep.  Garbage collector will not
    purge entries if there are fewer than this number.
    Default: 128

neigh/default/gc_thresh2 - INTEGER
    Threshold when garbage collector becomes more aggressive about
    purging entries. Entries older than 5 seconds will be cleared
    when over this number.
    Default: 512

neigh/default/gc_thresh3 - INTEGER
    Maximum number of non-PERMANENT neighbor entries allowed.  Increase
    this when using large numbers of interfaces and when communicating
    with large numbers of directly-connected peers.
    Default: 1024

为了溢出邻居表,您必须拥有多个gc_thresh3邻居表条目。在本例中,Kubernetes Pod 就是如此,因为每个 Pod 都有自己的网络命名空间,具有唯一的接口和唯一的 MAC 地址。

有很多容器!

如何调整这些值取决于您预期的服务负载。这是一次性的吗?什么也不做。不确定该怎么做?将所有值翻倍,然后等待结果。您知道您有 5000 个 Pod 吗?设置这些值,以免空间不足。

答案2

以下是我最终做的事情:

从所有服务器收集数据:

for n in ip netns; do echo -en "$n: "; sudo ip netns exec $n arp -an|wc -l; done 2>&1 | grep -v 'No such file or directory' > /tmp/arp.log

count=0for i in cat /tmp/arp.log|awk '{ print $2 }'; do count=expr $count + $i; done

echo $count

rm -f /tmp/arp.log

算出我的最高值,将其加倍,这个数字就是我的新值gc_thresh3

笔记:最后几个命令没有考虑到,有些容器正在使用主机网络,这意味着表中的实际条目数量可能较低。由于对 RAM 的影响很小,所以我并不关心这一点。

相关内容