Apache在CentOS 6上无反应

今天早上有两次,今天凌晨八点到九点,我们的Apache服务器没有响应,虽然服务显示为正在运行。 我们重置它与服务httpd重启,这似乎解决了这个问题。 在此之前,我们的服务器已经运行了大约三个月。

我读了另一篇文章,并将MaxClients和其他值从256更改为512,因为有一个“[错误]服务器达到MaxClients设置,考虑提高MaxClients设置”显示,但是在今天上午9:05。 今天早些时候没有一个人表示“崩溃”。

以下是一些当前的error_log:

[Tue Mar 31 01:22:11 2015] [error] [client 192.187.126.162] script '/home/www/www.pixelark.com/www/wp-login.php' not found or unable to stat [Tue Mar 31 02:09:13 2015] [error] [client 198.252.44.11] File does not exist: /home/www/www.pixelark.com/www/player.vimeo.com [Tue Mar 31 02:09:13 2015] [error] [client 198.252.44.11] File does not exist: /home/www/www.pixelark.com/www/player.vimeo.com [Tue Mar 31 02:32:59 2015] [error] [client 188.165.233.228] File does not exist: /home/www/www.pixelark.com/www/calvarycch [Tue Mar 31 02:34:29 2015] [error] [client 27.104.199.92] File does not exist: /home/www/www.pixelark.com/www/apple-touch-icon.png [Tue Mar 31 02:37:19 2015] [error] [client 66.74.91.61] File does not exist: /home/www/www.pixelark.com/www/apple-touch-icon-precomposed.png [Tue Mar 31 02:37:19 2015] [error] [client 66.74.91.61] File does not exist: /home/www/www.pixelark.com/www/apple-touch-icon.png [Tue Mar 31 02:57:31 2015] [error] [client 173.184.225.8] File does not exist: /home/www/www.pixelark.com/www/apple-touch-icon.png [Tue Mar 31 07:36:29 2015] [notice] caught SIGTERM, shutting down [Tue Mar 31 07:36:29 2015] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0 [Tue Mar 31 07:36:29 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) [Tue Mar 31 07:36:29 2015] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366) [Tue Mar 31 07:36:29 2015] [notice] Digest: generating secret for digest authentication ... [Tue Mar 31 07:36:29 2015] [notice] Digest: done [Tue Mar 31 07:36:30 2015] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366) [Tue Mar 31 07:36:30 2015] [notice] Apache/2.2.15 (Unix) DAV/2 mod_ssl/2.2.15 OpenSSL/1.0.1e-fips configured -- resuming normal operations [Tue Mar 31 07:44:21 2015] [error] [client 68.6.150.73] File does not exist: /home/www/www.pixelark.com/www/apple-touch-icon-120x120-precomposed.png [Tue Mar 31 08:23:02 2015] [error] [client 172.56.0.75] File does not exist: /home/www/www.pixelark.com/www/apple-touch-icon-precomposed.png [Tue Mar 31 08:23:02 2015] [error] [client 172.56.0.75] File does not exist: /home/www/www.pixelark.com/www/apple-touch-icon.png [Tue Mar 31 08:45:35 2015] [error] [client 173.208.203.138] File does not exist: /home/www/www.pixelark.com/www/readme.asp [Tue Mar 31 08:56:53 2015] [error] [client 184.176.137.140] File does not exist: /home/www/www.pixelark.com/www/apple-touch-icon-precomposed.png [Tue Mar 31 08:56:53 2015] [error] [client 184.176.137.140] File does not exist: /home/www/www.pixelark.com/www/apple-touch-icon.png [Tue Mar 31 09:05:13 2015] [error] server reached MaxClients setting, consider raising the MaxClients setting [Tue Mar 31 09:11:54 2015] [notice] caught SIGTERM, shutting down [Tue Mar 31 09:11:55 2015] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0 [Tue Mar 31 09:11:55 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) [Tue Mar 31 09:11:55 2015] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366) [Tue Mar 31 09:11:55 2015] [notice] Digest: generating secret for digest authentication ... [Tue Mar 31 09:11:55 2015] [notice] Digest: done [Tue Mar 31 09:11:55 2015] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366) [Tue Mar 31 09:11:55 2015] [notice] Apache/2.2.15 (Unix) DAV/2 mod_ssl/2.2.15 OpenSSL/1.0.1e-fips configured -- resuming normal operations [Tue Mar 31 09:17:13 2015] [notice] caught SIGTERM, shutting down [Tue Mar 31 09:17:13 2015] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0 [Tue Mar 31 09:17:13 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) [Tue Mar 31 09:17:14 2015] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366) [Tue Mar 31 09:17:14 2015] [notice] Digest: generating secret for digest authentication ... [Tue Mar 31 09:17:14 2015] [notice] Digest: done [Tue Mar 31 09:17:14 2015] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366) [Tue Mar 31 09:17:14 2015] [notice] Apache/2.2.15 (Unix) DAV/2 mod_ssl/2.2.15 OpenSSL/1.0.1e-fips configured -- resuming normal operations [Tue Mar 31 09:20:04 2015] [error] [client 107.143.147.89] File does not exist: /home/www/www.pixelark.com/www/apple-touch-icon-precomposed.png [Tue Mar 31 09:20:05 2015] [error] [client 107.143.147.89] File does not exist: /home/www/www.pixelark.com/www/apple-touch-icon.png [Tue Mar 31 09:23:15 2015] [notice] caught SIGTERM, shutting down [Tue Mar 31 09:21:07 2015] [notice] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0 [Tue Mar 31 09:21:07 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) [Tue Mar 31 09:21:08 2015] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366) [Tue Mar 31 09:21:08 2015] [notice] Digest: generating secret for digest authentication ... [Tue Mar 31 09:21:08 2015] [notice] Digest: done [Tue Mar 31 09:21:09 2015] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366) [Tue Mar 31 09:21:09 2015] [notice] Apache/2.2.15 (Unix) DAV/2 mod_ssl/2.2.15 OpenSSL/1.0.1e-fips configured -- resuming normal operations [Tue Mar 31 09:21:12 2015] [error] [client 119.74.155.16] File does not exist: /home/www/www.pixelark.com/www/cscc, referer: http://pixelark.com/cscc/recent/mobile/mobile [Tue Mar 31 09:24:18 2015] [error] [client 119.74.155.16] PHP Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/www/www.pixelark.com/db.php on line 9 [Tue Mar 31 09:24:18 2015] [error] [client 119.74.155.16] PHP Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /home/www/www.pixelark.com/db.php on line 10 [Tue Mar 31 09:24:18 2015] [error] [client 119.74.155.16] PHP Warning: mysql_query() [<a href='function.mysql-query'>function.mysql-query</a>]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/www/www.pixelark.com/www/mobile_controller/index.php on line 23 [Tue Mar 31 09:24:18 2015] [error] [client 119.74.155.16] PHP Warning: mysql_query() [<a href='function.mysql-query'>function.mysql-query</a>]: A link to the server could not be established in /home/www/www.pixelark.com/www/mobile_controller/index.php on line 23 [Tue Mar 31 09:24:18 2015] [error] [client 119.74.155.16] PHP Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/www/www.pixelark.com/www/mobile_controller/index.php on line 29 

您将需要更多信息来进行debugging,例如当时连接的客户端数量以及冻结时正在使用的页面数量。

通常,只有当应用程序端错误出现问题时,才会到达MaxClients,客户端将请求一个页面,并且应用程序将花费很长时间来回应客户端。 根据我的经验,当最近的代码更改引入错误时,或者应用程序代码依赖于数据库或文件系统,以及该数据库或文件系统缓慢或不可用等时,此问题就会出现。这在Apache中很less出现问题本身。 有许多可能的应用方面的原因。

如果瓶颈是文件系统或数据库,那么MaxClients从256增加到512就可能使问题变得更糟,因为现在有两倍的客户端连接到有问题的资源。

为了从Apache的angular度提供更多的问题可见性:

  1. 查看Apache访问日志以确定哪些页面最受欢迎。
  2. 启用mod_status将打印服务器性能信息,并将打印有关所有当前会话的信息。 按照“ 使用服务器状态”进行故障排除一节中的build议,启用ExtendedStatus 。 出于安全原因,限制访问一组安全的IP地址。
  3. http://your.server.name/server-status?auto监控状态页面&#x3002; 您可以通过浏览器或命令行使用service httpd fullstatus (请参阅https://www.liquidweb.com/kb/use-httpd-fullstatus-to-monitor-apache-status/为例)&#x3002; 您还可以使用service httpd fullstatus > /var/log/httpd.status.logservice httpd fullstatus | logger -t httpd-status命令将此信息捕获到日志文件service httpd fullstatus | logger -t httpd-status service httpd fullstatus | logger -t httpd-status ,并将其放入cron,或使用Cacti,Splunk或其他程序进行logging。

这应该为您提供更多关于系统冻结之前的状态的信息。