挂起的 LAMP 服务器需要检查哪些日志?

挂起的 LAMP 服务器需要检查哪些日志?

我正在运行 Centos 5.7。我在典型的 Web 托管服务器设置中运行 Apache、MySQL、PHP、Courier-IMAP、Qmail 和 Plesk 控制面板。它经常挂起。

由于没有 Plesk 或 SSH 访问,我必须通过管理面板重新启动服务器...如何防止这种情况再次发生?

处理器:AMD Phenom(tm) II X4
内存:8 GB

我注意到 Apache 日志中有一些错误:

# tail -20 /var/log/httpd/error_log

[Mon Sep 03 06:12:33 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/web
[Mon Sep 03 06:12:34 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/php-my-admin
[Mon Sep 03 06:12:34 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/websql
[Mon Sep 03 06:12:35 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/phpmyadmin
[Mon Sep 03 06:12:36 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/phpMyAdmin
[Mon Sep 03 06:12:36 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/phpMyAdmin-2
[Mon Sep 03 06:12:37 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/php-my-admin
[Mon Sep 03 06:12:38 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/phpMyAdmin-2.2.3
[Mon Sep 03 06:12:38 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/phpMyAdmin-2.2.6
[Mon Sep 03 06:12:39 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/phpMyAdmin-2.5.1
[Mon Sep 03 06:12:39 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/phpMyAdmin-2.5.4
[Mon Sep 03 06:12:40 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/phpMyAdmin-2.5.5-rc1
[Mon Sep 03 06:12:41 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/phpMyAdmin-2.5.5-rc2
[Mon Sep 03 06:12:41 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/phpMyAdmin-2.5.5
[Mon Sep 03 06:12:42 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/phpMyAdmin-2.5.5-pl1
[Mon Sep 03 06:12:43 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/phpMyAdmin-2.5.6-rc1
[Mon Sep 03 06:12:43 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/phpMyAdmin-2.5.6-rc2
[Mon Sep 03 06:12:44 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/phpMyAdmin-2.5.6
[Mon Sep 03 06:12:45 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/phpMyAdmin-2.5.7
[Mon Sep 03 06:12:45 2012] [error] [client 202.29.34.28] File does not exist: /var/www/vhosts/default/htdocs/phpMyAdmin-2.5.7-pl1

还注意到一些mysql慢查询:

# Query_time: 23.734215  Lock_time: 0.000111 Rows_sent: 1  Rows_examined: 2501281
use yasooyam_yasoodb;
SET timestamp=1346149823;
SELECT COUNT(user_history_product.ID) FROM user_history_product WHERE user_history_product.PRODUCT_ID=915;

# Query_time: 293.916966  Lock_time: 1.163037 Rows_sent: 1  Rows_examined: 2501280
SET timestamp=1346149823;
SELECT COUNT(user_history_product.ID) FROM user_history_product WHERE user_history_product.PRODUCT_ID=172;

# Query_time: 61.295134  Lock_time: 0.000345 Rows_sent: 331  Rows_examined: 331
use pumexinf_mdb;
SET timestamp=1346149825;
show tables;

# Query_time: 16.869923  Lock_time: 2.281526 Rows_sent: 1889  Rows_examined: 9330
use yasooyam_yasoodb;
SET timestamp=1346586973;
SELECT user_items.ID, user_items.TYPE, user_items.USER_ID, user_items.SHOW_IN, user_items.CATEGORY, user_items.SUB_CATEGORY, user_items.COUNTRY, user_items.LANGUAGE, user_items.TITLE, user_items.START_TIME, user_items.END_TIME, user_items.DATE, user_items.DESCRIPTION, user_items.ATTACH, user_items.IMAGE, user_items.IMAGE_AUTHOR, user_items.IMAGE_SOURCE, user_items.VIDEO_URL, user_items.THUMB, user_items.AUTHOR, user_items.SOURCE, user_items.CREATE_DATE, user_items.UPDATE_DATE, user_items.STATUS FROM user_items WHERE user_items.TYPE=9 AND user_items.STATUS=1;

答案1

根据 apache2 日志,挂起肯定不是致命错误(未找到文件)的结果。

这取决于您在 my.cnf 中为 mysqld 允许了多少内存。

您需要进一步调查为什么会出现这种情况。

调查时需要注意以下几点:

  • 服务器挂起(拒绝服务)可能是由两个原因造成的,处理器负载过大或应用程序导致拒绝服务。
  • 检查系统日志而不是应用程序日志以获得更多见解
  • 采取预防措施,安装deflateDOSSELinux检查他们的日志
  • 记住这样的命令topnetstat它们会非常有用。

答案2

尝试安装一个监控软件,例如穆宁。使用 munins 插件,您可以随时间监控很多事情。例如,在服务器挂起之前,您可以看到 Apache 请求、磁盘 I/O 或 mysql 连接出现峰值。有了这样的软件,找到挂起的根源就容易多了。

相关内容