工作,学习,生活,这里将会有一些记录. 备用域名:http://meisw.51099.com 注册 | 登陆
浏览模式: 标准 | 列表2009年11月的文章

解决apache服务器的time_wait和fin_wait1过多等问题

对一些大流量的web服务器来说,比较常见的问题就是time_wait会很多,起因大多都是apache里 keepalive 没开的原因,将这个开启,相对会少一些,但大流量时还是比较多,这里还有另外一个参数设置

net.ipv4.tcp_max_tw_buckets = 5000

如果不想time_wait不要太多,只要把这个值调低,就肯定不会超过了

但会出现一个新问题,就是在系统日志里,会很多类似这样的警告

Nov 27 15:50:01 localhost kernel: printk: 9498 messages suppressed.
Nov 27 15:50:01 localhost kernel: TCP: time wait bucket table overflow
Nov 27 15:50:06 localhost kernel: printk: 9562 messages suppressed.
Nov 27 15:50:06 localhost kernel: TCP: time wait bucket table overflow
Nov 27 15:50:11 localhost kernel: printk: 10120 messages suppressed.
Nov 27 15:50:11 localhost kernel: TCP: time wait bucket table overflow
Nov 27 15:50:16 localhost kernel: printk: 9182 messages suppressed.
Nov 27 15:50:16 localhost kernel: TCP: time wait bucket table overflow
Nov 27 15:50:21 localhost kernel: printk: 9626 messages suppressed.

这个警告其实不影响使用和性能,只是烦而已。我曾为避免这个提示,就将 net.ipv4.tcp_max_tw_buckets 调得很大,接着 time_wait 也就很大了。这也是上面这个问题,在网上搜索到的解决办法了。不想这个警告出现,重新编译内核,可以避免。

还有另一外问题,就是 fin_wait1 过多的问题,这个情况,一般的服务器上不会有。至少我的情况是这样

但在用了集群/负载均衡(LVS)中,下面的机器,就有这种情况,也曾为解决这个问题苦恼了挺久,经过今天的测试,也可以解决了。

只要在/etc/sysctl.conf 中加入

net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_intvl = 15
net.ipv4.tcp_retries2 = 5
net.ipv4.tcp_orphan_retries = 3
net.ipv4.tcp_reordering = 5
net.ipv4.tcp_retrans_collapse = 0

就会减少很多了,关键的是 net.ipv4.tcp_orphan_retries 这个

不打开机箱,就知道内存使用情况(转)

在考虑添加内存的时候,经常需要清楚服务器最大支持多少内存,已经有多少内存。有多少插槽,已经用了几个插槽,但这原来一般都需要打开机箱查看同时参考原厂资料,非常麻烦。偶经过一段时间琢磨、试验,发现通过dmidecode的信息可以搞定以上的事情。

l 内存的插槽数,已经使用多少插槽.每条内存多大,已使用内存多大

 

dmidecode |grep -P -A 5 "Memory/s+Device"|grep Size:|grep -v Range

 

例:

#dmidecode |grep -P -A 5 "Memory/s+Device"|grep Size:|grep -v Range
Size: 512 MB
Size: 512 MB
Size: No Module Installed
Size: No Module Installed

说明该服务器:

有4个内存插槽
已经使用2个内存插槽
每条内存容量512M
还有2个内存插槽可用

2 支持的最大内存容量

 

dmidecode |grep -P "Maximum/s+Capacity"

 

例:

# dmidecode |grep -P "Maximum/s+Capacity"
 Maximum Capacity: 4 GB

说明该服务器支持的最大内存容量是4GB
同时由此可以得出该服务器支持的单条内存最大容量是1G

sysstat