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도움이 될 수 있는 몇 가지 일반적인 솔루션을 제공하려고 노력했습니다.

  1. mysqld에서 매개변수를 조정해 보세요 /etc/my.cnf. 메모리 소비를 줄이는 방법을 Google에 문의하세요 mysql.

  2. apache/nginx+의 메모리 사용량은 Apache를 직접 사용하는 것 php-fpm보다 php적다고 생각합니다. 두 경우 모두 최대 스레드 수 php, 스레드당 메모리 등을 제어할 수 있습니다. 거기에 약간의 조정을 해주세요.

  3. 가장 중요한 것은 mysqld로그 apache2파일 등을 분석하는 것입니다. man기본 로그 파일 위치에 대한 페이지를 읽고 오류를 찾으십시오.

그것이 도움이 되기를 바랍니다.

관련 정보