我有一台自管理的 VPS,是从公司前任管理员那里继承的,上面运行着许多 Wordpress 网站。该 VPS 有 2 个 CPU、6GB RAM,运行 Ubuntu 10.04 64 位。
我注意到服务器很慢,有时非常慢。所以我使用top
命令检查正在运行的内容,发现有许多 apache2 服务运行时间很长,有时长达 60 分钟。CPU 和内存使用率达到最高。
apache2 进程通常运行时间过长 - 从 4 分钟到 8、15、30、45 甚至一小时,堵塞 CPU 和内存并基本上杀死所有东西。
- 我大幅降低了 MaxClients 的数量
- 我逐个删除了所有 Apache 模块,只保留了网站正常运行所需的模块
- 我使用垃圾邮件和 http 请求过滤器保护了所有应用程序
什么都没改变。
我如何才能查明问题的根源?我们所有的 wordpress 都是安全的,既可以拒绝意外请求,又可以保护非标准登录页面和自动阻止机器人。
我想追踪问题并修复它,以便 VPS 能够顺利运行。
其结果如下apache2ctl -S
:
109.228.21.231:80 is a NameVirtualHost
default server server109-228-21-231.live-servers.net (/etc/apache2/plesk.conf.d/ip_default/server109-228-21-231.live-servers.net.conf:8)
port 80 namevhost server109-228-21-231.live-servers.net (/etc/apache2/plesk.conf.d/ip_default/server109-228-21-231.live-servers.net.conf:8)
port 80 namevhost default (/etc/apache2/plesk.conf.d/server.conf:67)
port 80 namevhost lists (/etc/apache2/plesk.conf.d/server.conf:139)
port 80 namevhost atmail.webmail (/etc/apache2/plesk.conf.d/atmail.conf:9)
port 80 namevhost horde.webmail (/etc/apache2/plesk.conf.d/horde.conf:9)
port 80 namevhost accessaa.co.uk (/etc/apache2/plesk.conf.d/vhosts/accessaa.co.uk.conf:112)
port 80 namevhost bighandmedia.org (/etc/apache2/plesk.conf.d/vhosts/bighandmedia.org.conf:8)
port 80 namevhost c-mw.net (/etc/apache2/plesk.conf.d/vhosts/c-mw.net.conf:8)
port 80 namevhost centralexhibitioncentres.org (/etc/apache2/plesk.conf.d/vhosts/centralexhibitioncentres.org.conf:8)
port 80 namevhost conference-news.co.uk (/etc/apache2/plesk.conf.d/vhosts/conference-news.co.uk.conf:112)
port 80 namevhost engage-magazine.co.uk (/etc/apache2/plesk.conf.d/vhosts/engage-magazine.co.uk.conf:8)
port 80 namevhost exhibitingmagazine.co.uk (/etc/apache2/plesk.conf.d/vhosts/exhibitingmagazine.co.uk.conf:8)
port 80 namevhost exhibitionnews.co.uk (/etc/apache2/plesk.conf.d/vhosts/exhibitionnews.co.uk.conf:8)
port 80 namevhost exhibitionworld.co.uk (/etc/apache2/plesk.conf.d/vhosts/exhibitionworld.co.uk.conf:124)
port 80 namevhost h2openmagazine.com (/etc/apache2/plesk.conf.d/vhosts/h2openmagazine.com.conf:103)
port 80 namevhost holdsworthevents.co.uk (/etc/apache2/plesk.conf.d/vhosts/holdsworthevents.co.uk.conf:8)
port 80 namevhost om-pa.co.uk (/etc/apache2/plesk.conf.d/vhosts/om-pa.co.uk.conf:8)
port 80 namevhost peoplepeoplemedia.co.uk (/etc/apache2/plesk.conf.d/vhosts/peoplepeoplemedia.co.uk.conf:8)
port 80 namevhost productivepr.org (/etc/apache2/plesk.conf.d/vhosts/productivepr.org.conf:8)
port 80 namevhost redpavementgroup.com (/etc/apache2/plesk.conf.d/vhosts/redpavementgroup.com.conf:8)
port 80 namevhost show-pro.co.uk (/etc/apache2/plesk.conf.d/vhosts/show-pro.co.uk.conf:8)
port 80 namevhost stgeorgeshalls.com (/etc/apache2/plesk.conf.d/vhosts/stgeorgeshalls.com.conf:76)
port 80 namevhost whitebook.co.uk (/etc/apache2/plesk.conf.d/vhosts/whitebook.co.uk.conf:8)
port 80 namevhost www.redrecruitment.net (/etc/apache2/plesk.conf.d/vhosts/www.redrecruitment.net.conf:8)
port 80 namevhost exhibitionnewsawards.co.uk (/etc/apache2/plesk.conf.d/forwarding/exhibitionnewsawards.co.uk_httpd.conf:6)
109.228.21.231:443 is a NameVirtualHost
default server default-109_228_21_231 (/etc/apache2/plesk.conf.d/server.conf:103)
port 443 namevhost default-109_228_21_231 (/etc/apache2/plesk.conf.d/server.conf:103)
port 443 namevhost lists (/etc/apache2/plesk.conf.d/server.conf:168)
port 443 namevhost atmail.webmail (/etc/apache2/plesk.conf.d/atmail.conf:58)
port 443 namevhost horde.webmail (/etc/apache2/plesk.conf.d/horde.conf:46)
port 443 namevhost accessaa.co.uk (/etc/apache2/plesk.conf.d/vhosts/accessaa.co.uk.conf:10)
port 443 namevhost conference-news.co.uk (/etc/apache2/plesk.conf.d/vhosts/conference-news.co.uk.conf:10)
port 443 namevhost exhibitionworld.co.uk (/etc/apache2/plesk.conf.d/vhosts/exhibitionworld.co.uk.conf:10)
port 443 namevhost h2openmagazine.com (/etc/apache2/plesk.conf.d/vhosts/h2openmagazine.com.conf:10)
port 443 namevhost stgeorgeshalls.com (/etc/apache2/plesk.conf.d/vhosts/stgeorgeshalls.com.conf:10)
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server server109-228-21-231.live-servers.net (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost server109-228-21-231.live-servers.net (/etc/apache2/sites-enabled/000-default:1)
Syntax OK
答案1
要检查特定 apache2 进程正在做什么,请使用 strace。
# strace -p <pid>
查看系统调用并找到自己的方法。