关于Apache连接数限制的设置

昨天晚上收到监视团队的电话,说web服务器连不上。(作为DBA,这貌似超出了我的工作范畴啊...)

于是马上VPN连上服务器,发现网络负载均衡下的两台Apache服务器都没有响应,而服务器OS层面上正常。 大概十来分钟后自动恢复正常。

 

通过检查Apache的错误日志,两台服务器都发现了类似如下的错误,而且错误发生的时间几乎是同时。

[Thu Sep 18 20:46:13 2014] [warn] Server ran out of threads to serve requests. Consider raising the ThreadsPerChild setting

[Thu Sep 18 20:50:54 2014] [warn] (OS 64)指定的网络名不再可用。  : winnt_accept: Asynchronous AcceptEx failed.

[Thu Sep 18 20:50:54 2014] [warn] (OS 64)指定的网络名不再可用。  : winnt_accept: Asynchronous AcceptEx failed.

[Thu Sep 18 20:50:54 2014] [warn] (OS 64)指定的网络名不再可用。  : winnt_accept: Asynchronous AcceptEx failed.

 

原来是向Apache服务器请求的Request已经超过了所设置的同时连接数。

检查后发现我们的两台Apache服务器除了有个lb设置,其它都是默认的......

 

于是,我修改了如下配置:

修改D:\webServer\conf\extra\httpd-mpm.conf文件

<IfModule mpm_winnt_module>

ThreadsPerChild 512

MaxRequestsPerChild 5000

</IfModule>

修改D:\webServer\conf\httpd.conf文件,将下面的注释#解除。

#Include conf/extra/httpd-mpm.conf

 

同时,为了能监视目前的连接数,进行了如下设置修改:

修改D:\webServer\conf\httpd.conf文件,将下面的注释#解除。

#Include conf/extra/httpd-info.conf

修改D:\webServer\conf\extra\httpd-info.conf文件,增加如下内容:

<location /c-server-status>

SetHandler server-status

Order Deny,Allow

Deny from nothing

Allow from all

</location>

这样,通过 web服务器ip/c-server-status 可以监视Apache目前的状态。

关闭/启动Apache服务器,打完收工。

 

下面是通过Zabbix监视apache的设置例子: http://www.infoscoop.org/blogjp/2014/09/01/zabbix-apache-monitoring/

posted on 2014-09-19 14:43  万剑齐发  阅读(484)  评论(0编辑  收藏  举报