centos6.8 apache執行一段時間 訪問不了的情況(已解決)
網站突然一下子訪問不了了
第一反應 重啟apache 恢復正常
後續工作就是排查原因
tail -100 error_log
[Fri Sep 28 11:20:43 2018] [error] server reached MaxClients setting, consider raising the MaxClients setting [Fri Sep 28 11:25:29 2018] [notice] caught SIGTERM, shutting down [Fri Sep 28 11:25:30 2018] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) [Fri Sep 28 11:25:30 2018] [notice] Digest: generating secret for digest authentication ... [Fri Sep 28 11:25:30 2018] [notice] Digest: done [Fri Sep 28 11:25:30 2018] [notice] Apache/2.2.15 (Unix) DAV/2 PHP/5.6.37 mod_ssl/2.2.15 OpenSSL/1.0.1e-fips configured -- resuming normal operations 大體翻譯就是當前併發數超過設定連結數
ps -ef | grep httpd | wc -l
查詢apache併發連線數
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
檢視linux tcp連線數
/usr/sbin/httpd -l
檢視prefork還是worker模式
我這裡是prefork模式
去httpd.conf下配置
<IfModule prefork.c> StartServers 8 MinSpareServers 5 MaxSpareServers 20 ServerLimit 256 MaxClients 256 MaxRequestsPerChild 4000 </IfModule>
修改成
<IfModule prefork.c> StartServers 100 MinSpareServers 100 MaxSpareServers 100 ServerLimit 1024 MaxClients 1024 MaxRequestsPerChild 4000 </IfModule>
重啟apache生效