freebsd mbuf资源用完的原因

/kernelAll mbuf clusters exhausted(精疲力尽), please see tuning(调整)(7). 解决


mail#tail -f /var/log/messages
Jul  1 11:28:06 mail /kernelAll mbuf clusters exhaustedplease see tuning(7).
Jul  1 11:28:06 mail pdns[198]: Error sending reply答复 with sendto (socket=7): No buffer缓冲区 space available可得到
Jul  1 11:28:07 mail last message repeated重复 5 times
Jul  1 11:28:07 mail /kernelAll mbuf clusters exhaustedplease see tuning(7).
Jul  1 11:28:07 mail pdns[198]: Error sending reply with sendto (socket=7): No buffer space available
Jul  1 11:28:08 mail /kernelAll mbuf clusters exhaustedplease see tuning(7).
Jul  1 11:28:39 mail last message repeated 29 times
Jul  1 11:30:40 mail last message repeated 105 times
Jul  1 11:32:52 mail last message repeated 111 times
Jul  1 12:39:52 mail pdns[198]: On retrieving检索 question of packet from 218.56.161.69, encountered遇见 error: Label claims宣称 to be longer than packet

mail# dmesg
All mbuf clusters exhaustedplease see tuning(7).
All mbuf clusters exhaustedplease see tuning(7).
...........................

mail# netstat -m
37/3840/10048 mbufs in use (current/peak/max):
        37 mbufs allocated to data
32/2512/2512 mbuf clusters in use (current/peak/max)
5984 Kbytes allocated分配 to network (79% of mb_map in use)
17044 requests请求 for memory denied否认
828 requests for memory delayed推迟
0 calls to protocol drain routines

 

 

将会满屏都是

从上面可以看出,All mbuf clusters exhausted,查原因得知,由于缺省的kern.ipc.nmbclusters比较小,以致于某些东东需要分配时得不到。延时828个。

俺查到:kern.ipc.nmbclusters可以调整用来增加系统愿意申请的网络mbuf的数量。每个cluster(簇)大概2K的内存,所以值1024代表保留2M内核内存作为网络缓冲区。 你可以简单的计算出需要多少。如果你有一个web服务器最多可以有1000个并发连接,每个连接吃掉16K接收和发送缓冲区,你大概需要32MB的网络缓冲区来对付它。一个比较粗糙的方法是乘以2,所以32MBx2 = 64MB/2K = 32768。所以这个情况下你将需要设置nmbclusters到32768。我们建议为那些内存不多的机器设置1024到4096而4096到32768为那些有很多内存的机器。无论如何如何你不能设置一个很随意的值,这可能导致启动时崩溃。netstat(1)的-m选项可以用来查看网络缓冲区的使用情况。老的FreeBSD系统没有这个sysctl,所以需要设置内核配置选项NMBCLUSTERS。

于上/boot/defaults/load.conf文件中增加了kern.ipc.nmbclusters="16384" ,重启可解决。因为俺是邮件服务器兼DNS,没必要整那么大。

另外,在/sys/i386/conf/的LINT文件中有这样一段:

options        NBUF=512

# Set the size of the mbuf KVM reservation, in clusters.  This is scaled
# by approximately 2048 bytes.  The system will auto-size the mbuf area
# to (512 + maxusers*16) if this option is not specified.
# maxusers is in turn computed at boot time depending on available memory
# or set to the value specified by "options MAXUSERS=x" (x=0 means
# autoscaling).
# So, to take advantage of autoscaling, you have to remove both
# NMBCLUSTERS and MAXUSERS (and NMBUFS) from your kernel config.
#
options        NMBCLUSTERS=1024

# Set the number of mbufs available in the system. Each mbuf
# consumes 256 bytes. The system will autosize this (to 4 times
# the number of NMBCLUSTERS, depending on other constraints)
# if this option is not specified.

传说改这个也是有效的。

arrow
arrow
    全站熱搜

    yves2005 發表在 痞客邦 留言(0) 人氣()