CentOS 6 上的 Apache 无响应

CentOS 6 上的 Apache 无响应

今天早上两次,今天凌晨的某个时候,然后大约早上 8-9 点,我们的 Apache 服务器没有响应,尽管服务显示正在运行。我们用 service httpd restart 重置了它,这似乎解决了这个问题。在此之前,我们的服务器已经正常运行了大约三个月。

我读了另一篇文章,将 MaxClients 和其他一些值从 256 改为 512,因为有显示“[错误] 服务器已达到 MaxClients 设置,请考虑提高 MaxClients 设置”,但那是今天上午 9:05。今天早上的“崩溃”没有显示任何内容。

以下是当前的一些错误日志:

[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

答案1

您将需要更多信息来调试这个问题,例如当时连接的客户端数量以及冻结时正在使用的页面。

通常,只有当应用程序端的错误导致问题时才会达到 MaxClients 值——客户端将请求一个页面,而应用程序将需要很长时间才能响应客户端。根据我的经验,当最近的代码更改引入错误时,或者当应用程序代码依赖于数据库或文件系统,而该数据库或文件系统速度很慢或不可用时,就会出现此问题。这很少是 Apache 本身的问题。应用程序端可能有很多原因。

如果瓶颈是文件系统或数据库,则将 MaxClients 从 256 提高到 512 可能会使问题变得更糟,因为现在连接到有问题的资源的客户端数量增加了一倍。

为了从 Apache 角度更清楚地了解该问题,请执行以下操作:

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

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

相关内容