我使用 WordPress 安装的 Ubuntu 16.04 不断打开 apache2 进程,占用内存

我使用 WordPress 安装的 Ubuntu 16.04 不断打开 apache2 进程,占用内存

服务器干净重启后,服务器就会正常。访问该网站并单击一些链接后,apache2 进程会被创建但从未终止,并且它不断占用越来越多的内存,直到服务器基本上崩溃。解决此问题的唯一方法是重新启动 apache2 服务以终止所有进程,或者再次重新启动服务器。

我的尝试包括恢复默认的 WordPress 主题并禁用所有插件,然后再次浏览网站,尽管问题似乎在事后仍然存在。我还尝试对 apache.conf 以及 php.ini 文件进行少量配置。

我现在很迷茫,并进行了研究,试图找出问题所在,但只是陷入了死胡同。

我的问题是,为什么 apache2 和 mysqld 占用这么多内存并阻止它们这样做以阻止我的服务器崩溃?

下面是当前正在运行的进程的图像,显​​示 apache 占用内存并生成多个 apache2 进程。

在此输入图像描述

阿帕奇错误日志:

[Fri Aug 10 18:15:48.070518 2018] [mpm_prefork:notice] [pid 7451] AH00169: caught SIGTERM, shutting down
[Fri Aug 10 18:15:48.948516 2018] [ssl:warn] [pid 11222] AH01909: 127.0.1.1:443:0 server certificate does NOT include an ID which matches the server name
[Fri Aug 10 18:15:49.143749 2018] [ssl:warn] [pid 11223] AH01909: 127.0.1.1:443:0 server certificate does NOT include an ID which matches the server name
[Fri Aug 10 18:15:49.154471 2018] [mpm_prefork:notice] [pid 11223] AH00163: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations
[Fri Aug 10 18:15:49.154530 2018] [core:notice] [pid 11223] AH00094: Command line: '/usr/sbin/apache2'

mmap() failed: [12] Cannot allocate memory

mmap() failed: [12] Cannot allocate memory

(Repeat . . . )

Apache 访问日志(可能是机器人造成的?):

5.9.61.232 - - [10/Aug/2018:18:40:11 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_orderby=rating&product_view=list HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:40:13 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=date&product_order=asc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:40:13 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=grid&product_order=asc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:40:23 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=grid&product_order=desc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:40:23 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=date&product_order=desc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:40:29 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=grid&product_orderby=date HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:40:29 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=date&product_view=grid HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:40:34 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=date&product_view=list HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:40:34 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=grid&product_orderby=default HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:40:41 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=default&product_count=16 HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:40:41 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=grid&product_orderby=name HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:40:49 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=default&product_order=asc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:40:49 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=grid&product_orderby=rating HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:40:55 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=list&product_orderby=date HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:40:54 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=default&product_order=desc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:41:01 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=default&product_view=grid HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:41:01 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=list&product_orderby=default HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:41:10 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=list&product_orderby=name HTTP/1.1" 200 436 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:41:12 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=list&product_orderby=popularity HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:41:10 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=default&product_view=list HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:41:14 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=name&product_count=16 HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:41:14 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=list&product_orderby=price HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:41:21 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=list&product_orderby=rating HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:41:21 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=name&product_order=asc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:41:30 +0000] "GET /product-category/personalized-jewelry/page/2/?prod&product_count=16&product_order&product_orderby=name HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:41:30 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=name&product_order=desc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:41:36 +0000] "GET /product-category/personalized-jewelry/page/2/?prod&product_count=16&product_order&product_orderby=price HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:41:36 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=name&product_view=grid HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:41:43 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=name&product_view=list HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:41:43 +0000] "GET /product-category/personalized-jewelry/page/2/?prod&product_count=16&product_order&product_orderby=rating HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:41:51 +0000] "GET /product-category/personalized-jewelry/page/2/?product_count=16&product_orderby=date&product_view&product_order=asc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:41:51 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=popularity&product_count=16 HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:42:02 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=popularity&product_order=asc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:42:02 +0000] "GET /product-category/personalized-jewelry/page/2/?product_count=16&product_orderby=default&product_view&product_order=asc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:42:10 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=popularity&product_order=desc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:42:10 +0000] "GET /product-category/personalized-jewelry/page/2/?product_count=16&product_orderby=popularity&product_view&product_order=desc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:42:20 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=popularity&product_view=grid HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:42:20 +0000] "GET /product-category/personalized-jewelry/page/3/?product_count=16&product_orderby=date&product_view&product_order=asc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:42:26 +0000] "GET /product-category/personalized-jewelry/page/3/?product_count=16&product_orderby=default&product_v HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:42:26 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=popularity&product_view=list HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:42:35 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=price&product_count=16 HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:42:35 +0000] "GET /product-category/personalized-jewelry/page/3/?product_count=16&product_orderby=rating&product_v HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:42:41 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=rating&product_view=grid HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:42:41 +0000] "GET /product-category/personalized-jewelry/page/3/?product_count=16&product_orderby=rating&product_v&product_order=desc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:42:49 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=rating&product_view=list HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:42:49 +0000] "GET /product-category/personalized-jewelry/page/5/?prod&product_count=16&product_order=desc&product_orderby=date HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:42:58 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_view=grid&product_count=16 HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:42:58 +0000] "GET /product-category/personalized-jewelry/page/5/?prod&product_count=16&product_order=desc&product_orderby=default HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"

答案1

您的网站似乎正在受到特别攻击性的网络爬虫的攻击。您可能会考虑是否可以从该机器人中排除您的网站或对其进行速率限制,或者如果它不是您特别关心的机器人,则可以在防火墙处阻止它。或者,您可以添加一个robots.txt文件到您的网站以阻止此类机器人。

答案2

htop图像中我认为mysqld比 apache 消耗更多的内存。我试图提供一些可能有帮助的通用解决方案。

  1. 尝试调整mysqld中的参数/etc/my.cnf。请谷歌一下如何减少mysql内存消耗。

  2. apache/nginx我认为+的内存占用php-fpmphp直接使用 apache 处理要少。在这两种情况下,您都可以控制最大线程数php、每个线程的内存等。请在那里进行一些微调。

  3. 最重要的是分析mysqld日志apache2文件等。阅读man默认日志文件位置的页面并查找任何错误。

希望,这就是帮助。

相关内容