.png)
6시간 동안 디버깅한 후 - 나는 이것을 포기합니다 :|
LAN에 거의 100개의 워드프레스가 있는 nginx+php-fpm+mysql이 있습니다(다양한 디자이너/개발자가 모두 테스트 워드프레스 설정에서 작업하고 사용함).
오랫동안 아무런 문제 없이 nginx를 사용하고 있습니다.
오늘 갑자기 nginx가 갑자기 "504 Gateway Time-out"을 반환하기 시작했습니다.
가상 호스트에 대한 nginx 오류 로그를 확인했습니다.
2010/09/06 21:24:24 [error] 12909#0: *349 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 21:25:11 [error] 12909#0: *349 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 21:25:11 [error] 12909#0: *443 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 21:25:12 [error] 12909#0: *443 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 22:08:32 [error] 12909#0: *1025 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 22:09:33 [error] 12909#0: *1025 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 22:09:40 [error] 12909#0: *1064 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 22:09:40 [error] 12909#0: *1064 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 22:24:44 [error] 12909#0: *1313 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 22:24:53 [error] 12909#0: *1313 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
TCP 모드를 통해 포트 9000에서 php-fpm을 실행하면서 "netstat | grep 9000"을 실행했는데 뭔가 이상한 것을 발견했습니다... (읽기 쉽도록 여기에 일부 출력을 붙여넣습니다)
tcp 9 0 localhost:9000 localhost:36094 CLOSE_WAIT 14269/php5-fpm
tcp 0 0 localhost:46664 localhost:9000 FIN_WAIT2 -
tcp 1257 0 localhost:9000 localhost:36135 CLOSE_WAIT -
tcp 1257 0 localhost:9000 localhost:36125 CLOSE_WAIT -
tcp 9 0 localhost:9000 localhost:36102 CLOSE_WAIT 14268/php5-fpm
tcp 0 0 localhost:46662 localhost:9000 FIN_WAIT2 -
tcp 745 0 localhost:9000 localhost:46644 CLOSE_WAIT -
tcp 0 0 localhost:46658 localhost:9000 FIN_WAIT2 -
tcp 1265 0 localhost:9000 localhost:46607 CLOSE_WAIT -
tcp 0 0 localhost:46672 localhost:9000 ESTABLISHED 12909/nginx: worker
tcp 1257 0 localhost:9000 localhost:36119 CLOSE_WAIT -
tcp 1265 0 localhost:9000 localhost:46613 CLOSE_WAIT -
tcp 0 0 localhost:46646 localhost:9000 FIN_WAIT2 -
tcp 1257 0 localhost:9000 localhost:36137 CLOSE_WAIT -
tcp 0 0 localhost:46670 localhost:9000 ESTABLISHED 12909/nginx: worker
tcp 1265 0 localhost:9000 localhost:46619 CLOSE_WAIT -
tcp 1336 0 localhost:9000 localhost:46668 ESTABLISHED -
tcp 0 0 localhost:46648 localhost:9000 FIN_WAIT2 -
tcp 1336 0 localhost:9000 localhost:46670 ESTABLISHED -
tcp 9 0 localhost:9000 localhost:36108 CLOSE_WAIT 14274/php5-fpm
tcp 1336 0 localhost:9000 localhost:46684 ESTABLISHED -
tcp 0 0 localhost:46674 localhost:9000 ESTABLISHED 12909/nginx: worker
tcp 1336 0 localhost:9000 localhost:46666 ESTABLISHED -
tcp 1257 0 localhost:9000 localhost:46648 CLOSE_WAIT -
tcp 1336 0 localhost:9000 localhost:46678 ESTABLISHED -
tcp 0 0 localhost:46668 localhost:9000 ESTABLISHED 12909/nginx: wo
아래에 강조 표시된 대로 "CLOSE_WAIT" 및 "FIN_WAIT2" 쌍이 많이 있습니다(위 출력에서).
tcp 1337 0 localhost:9000 localhost:46680 CLOSE_WAIT -
tcp 0 0 localhost:46680 localhost:9000 FIN_WAIT2 -
위의 포트 46680을 참고하세요.
mysql 느린 쿼리 오류 로그를 활성화했지만 작동하지 않았습니다.
현재 cronjob(아래 명령 참조)을 통해 매분마다 php5-fpm을 다시 시작하여 모든 것을 "부드럽게" 실행하지만 패치워크가 싫고 이 문제를 해결하고 싶습니다...
1 * * * * service php5-fpm restart > /dev/null
Google에서 광범위하게 검색했지만 도움을 얻지 못했습니다. 언급한 대로 이것은 LAN의 테스트 서버이며 CPU 로드는 0.10을 넘지 않으며 메모리 사용량도 25% 미만입니다(시스템에는 2GB RAM 및 우분투 서버가 설치되어 있음). 그래서 시간이 헷갈려서 도움을 드릴 수 없다면, 최소한 힌트라도 주세요.
도움을 주셔서 미리 감사드립니다.
-라훌
(참고 - 이것은 다음을 다시 게시하는 것입니다 -http://forum.nginx.org/read.php?11,127694)
업데이트: 아래에 게시된 답변을 찾았습니다.
답변1
nginx 포럼에 게시한 내용에서 답변을 찾았습니다.http://forum.nginx.org/read.php?2,127854
내 경우 대답은 다음과 같이 설정하는 것입니다.
request_terminate_timeout=30s
php-fpm 구성에서 (보통 /etc/php5/fpm/php-fpm.conf
)
30초 이외의 값도 사용할 수 있습니다.
나는 그것을 기본 php.ini
파일의 내 값과 일치시키는 데 사용했습니다.
max_execution_time = 30
모두 감사합니다. :-)
답변2
내 문제가 어떻게 해결되었는지는 다음과 같습니다.
http { 섹션에서 /etc/nginx/nginx.conf를 다음과 같이 변경합니다.
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
fastcgi_send_timeout 600s;
fastcgi_read_timeout 600s;
그런 다음 nginx를 다시 시작하십시오.
/etc/init.d/nginx 재시작
답변3
PHP 5.3을 사용하는 경우 백로그를 늘리십시오.
PHP 5.2를 사용하는 경우 패치를 백포트하여 백로그 크기를 128에서 늘립니다.
또한 TCP 소켓 대신 Unix 소켓을 사용하십시오. unix:/tmp/php5-cgi.sock (또는 관련 경로)
답변4
제 경우에는(동일한 nginx 오류 메시지) 문제가 있는 일부 PHP 스크립트가 실행이 끝나지 않고 무언가를 기다리기 때문에 더 이상 nginx가 선택할 수 있는 php5-fpm 하위 항목이 없습니다.
고치다:
- 다른 사람이 이 게시물에 언급한 실행 시간 제한을 추가하세요.
request_terminate_timeout=30s
- 아이들의 수를 키워라. 모든 것이 매력처럼 작동했습니다.
pm.max_spare_servers=16
pm.min_spare_servers=2
이제 모든 것이 매력처럼 작동했습니다.