
과부하 문제가 있습니다. 연결이 너무 많고 일부 IP에는 한 번에 20개 이상의 연결이 있습니다. 나는 이 명령을 한다.
netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
총 연결을 얻으려면 다음이 출력됩니다.
1 106.3.98.81
1 106.3.98.82
1 108.171.251.2
1 110.85.103.207
1 111.161.30.217
1 113.53.103.55
1 119.235.237.20
1 124.106.19.34
1 157.55.32.166
1 157.55.33.49
1 157.55.34.28
1 175.141.103.239
1 180.76.5.59
1 180.76.5.61
1 188.235.165.216
1 205.213.195.70
1 216.157.222.25
1 218.93.205.100
1 222.77.209.105
1 27.153.148.109
1 27.159.194.242
1 27.159.253.71
1 54.242.122.201
1 61.172.50.99
1 65.55.24.239
1 71.179.78.5
1 74.125.136.27
1 74.125.182.30
1 74.125.182.36
1 79.112.225.39
1 93.190.139.208
2 124.227.191.67
2 157.55.33.84
2 157.55.35.34
2 190.66.3.107
2 203.87.153.38
2 220.161.119.3
2 221.6.15.156
2 27.153.148.116
2 27.159.197.0
2 96.47.224.42
3 202.14.70.1
3 218.6.15.42
3 222.77.218.226
3 222.77.224.187
3 37.59.66.100
3 46.4.181.244
3 87.98.254.192
3 91.207.8.62
4 188.143.233.222
4 218.108.168.166
4 221.12.154.18
4 93.182.157.8
4 94.142.128.183
5 180.246.170.187
5 8.21.6.226
6 178.137.94.87
6 218.93.205.112
7 199.15.234.222
9
9 125.253.97.6
10 178.137.17.196
11 46.118.192.179
12 212.79.14.14
21 72.201.187.135
27 0.0.0.0
누구든지 나에게 몇 가지 지침을 줄 수 있습니까? 이 때문에 이번 주에 내 서버가 몇 번 충돌했습니다.
감사해요.
편집하다:
알겠습니다. 내 오류 로그에는 다음과 같은 내용이 나와 있습니다.
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4842 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4843 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4855 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4856 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4861 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4869 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4872 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4873 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4874 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4875 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4876 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4880 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4882 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4885 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4897 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4900 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4901 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4906 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4907 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4925 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4926 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4927 exit, attempting to continue anyway
[Thu Oct 18 12:17:39 2012] [error] could not make child process 4931 exit, attempting to continue anyway
[Thu Oct 18 12:17:40 2012] [notice] caught SIGTERM, shutting down
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613+lfs/curl.iso' - /usr/lib/php5/20060613+lfs/curl.iso: cannot open shared object file: No such file or directory in Unknown on line 0
[Thu Oct 18 12:17:45 2012] [notice] Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny10 with Suhosin-Patch configured -- resuming normal operations
그리고 나는 수천 개가 넘는 줄을 가지고 있습니다:(각각 다른 프로세스 ID를 가지고 있습니다)
[Thu Oct 18 12:17:38 2012] [error] child process 4906 still did not exit, sending a SIGKILL
그리고 나는 또한 다음과 같은 말을 했습니다:
[Wed Oct 17 09:44:58 2012] [error] server reached MaxClients setting, consider raising the MaxClients setting
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 50
MaxClients 300
MaxRequestsPerChild 5000
</IfModule>
답변1
해당 명령은 연결 상태를 무시합니다. 다음 명령은 해당 상태의 연결만 표시합니다 ESTABLISHED
.
netstat -anp |grep 'tcp\|udp' | awk '/ESTABLISHED/ {print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
이것은 그룹화하고 집계합니다.
netstat -tn | awk '/tcp/ {print $5, $6}' | sed 's/:[^ ]*//' | sort | uniq -c | sort -n
몇 가지 추가 질문:
- "내 서버가 충돌했습니다"란 무엇을 의미합니까? OS를 재부팅하시겠습니까? 아파치가 응답하지 않습니까? 정확히무슨 일이에요.
- 연결 수가 "충돌"의 원인인지 어떻게 알 수 있습니까? "연결이 너무 많아 중단 중입니다."라는 오류 메시지가 표시되는 경우. 그러면 좋을 것 같아요. 그렇지 않다면 성급한 결론을 내리기 전에 조사해 보도록 하겠습니다.