Ist es möglich, jeder IP eine Verbindung zuzuweisen?

Ist es möglich, jeder IP eine Verbindung zuzuweisen?

Ich habe Überlastungsprobleme. Zu viele Verbindungen und einige IPs haben mehr als 20 Verbindungen gleichzeitig. Ich führe diesen Befehl aus.

netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

Um die Gesamtzahl der Verbindungen zu erhalten, ist dies die Ausgabe:

      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

Kann mir jemand einige Anweisungen geben? Mein Server ist deswegen diese Woche mehrmals abgestürzt.

Danke.

BEARBEITEN:

Okay, in meinem Fehlerprotokoll steht:

[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

Und ich habe über tausend Zeilen mit folgendem Inhalt: (jede hat eine andere Prozess-ID)

[Thu Oct 18 12:17:38 2012] [error] child process 4906 still did not exit, sending a SIGKILL

Und ich habe auch eine Zeile, die besagt:

[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>

Antwort1

Dieser Befehl ignoriert den Status der Verbindung. Der folgende Befehl zeigt nur die Verbindungen im ESTABLISHEDStatus an.

netstat -anp |grep 'tcp\|udp' | awk '/ESTABLISHED/ {print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

Dieses hier gruppiert und aggregiert sie:

netstat -tn | awk '/tcp/ {print $5, $6}' | sed 's/:[^ ]*//' | sort | uniq -c | sort -n

Noch ein paar Fragen:

  1. Was meinen Sie mit „mein Server ist abgestürzt“? Neustart des Betriebssystems? Apache reagiert nicht? genauwas ist passiert.
  2. Woher wissen Sie, dass die Anzahl der Verbindungen die Ursache für den „Absturz“ war? Wenn Sie eine Fehlermeldung erhalten, die besagt: „Zu viele Verbindungen; Abbruch.“ wäre das gut. Wenn nicht, untersuchen wir das, bevor wir voreilige Schlüsse ziehen.

verwandte Informationen