/kernel: All mbuf clusters exhausted, please see tuning(7). 解决
mail#tail -f /var/log/messages
Jul 1 11:28:06 mail /kernel: All mbuf clusters exhausted, please 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 /kernel: All mbuf clusters exhausted, please 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 /kernel: All mbuf clusters exhausted, please 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 exhausted, please see tuning(7).
All mbuf clusters exhausted, please 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。
另外,在/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.
传说改这个也是有效的。