什么是日志来检查挂起的LAMP服务器?

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

我不得不通过pipe理面板重新启动服务器,因为没有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; 

Hang肯定不是(文件未find)的致命错误的结果 – 根据apache2日志。

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

你需要进一步调查一下为什么这是悬而未决的。

几件事要注意调查:

  • 服务器挂起(拒绝服务)可能是由于2件事情,处理器负载过重或导致拒绝服务的应用程序造成的。
  • 检查系统日志而不是应用程序日志以获取更多见解
  • 通过安装deflateDOS和SELinux来预防措施检查日志
  • 请记住像topnetstat这样的netstat它们派上用场了很多。

尝试安装像Munin这样的监控软件。 随着munins插件,你可以随时监控很多事情。 例如,您可以在服务器挂起或磁盘I / O或mysql连接之前看到Apache请求中的尖峰。 有了这样的软件,findhangup的来源要容易得多。