Apache immer down

fux0312

New Member
Hallo,

ich habe folgendes Probelm:
Der Apache ist öfters down und genau nach folgendem Log:
[Fri Aug 22 18:53:12 2008] [emerg] (22)Invalid argument: couldn't grab the accept mutex
Ok, laut Support ist der Server überlastet. Da ich aber daran nichts ändern kann muss ich den Server also anders hinbekommen.

Ich möchte, dass der Apache, wenn down automatisch neu gestartet wird. Am besten per bash oder so.

Kann mir da einer helfen?

Hier meine Apache server-tuning.conf:
##
## Server-Pool Size Regulation (MPM specific)
##

# the MPM (multiprocessing module) is not a dynamically loadable module in the
# sense of other modules. It is a compile time decision which one is used. We
# provide different apache2 MPM packages, containing different httpd2 binaries
# compiled with the available MPMs. See APACHE_MPM in /etc/sysconfig/apache2.

# prefork MPM
<IfModule prefork.c>
# number of server processes to start
# mpm_common - Apache HTTP Server
StartServers 5
# minimum number of server processes which are kept spare
# prefork - Apache HTTP Server
MinSpareServers 5
# maximum number of server processes which are kept spare
# prefork - Apache HTTP Server
MaxSpareServers 10
# highest possible MaxClients setting for the lifetime of the Apache process.
# mpm_common - Apache HTTP Server
ServerLimit 150
# maximum number of server processes allowed to start
# mpm_common - Apache HTTP Server
MaxClients 150
# maximum number of requests a server process serves
# mpm_common - Apache HTTP Server
MaxRequestsPerChild 10000
</IfModule>

# worker MPM
<IfModule worker.c>
# initial number of server processes to start
# mpm_common - Apache HTTP Server
StartServers 3
# minimum number of worker threads which are kept spare
# mpm_common - Apache HTTP Server
MinSpareThreads 25
# maximum number of worker threads which are kept spare
# mpm_common - Apache HTTP Server
MaxSpareThreads 75
# upper limit on the configurable number of threads per child process
# mpm_common - Apache HTTP Server
ThreadLimit 64
# maximum number of simultaneous client connections
# mpm_common - Apache HTTP Server
MaxClients 150
# number of worker threads created by each child process
# mpm_common - Apache HTTP Server
ThreadsPerChild 25
# maximum number of requests a server process serves
# mpm_common - Apache HTTP Server
MaxRequestsPerChild 10000
</IfModule>


#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 15

#
# EnableMMAP: Control whether memory-mapping is used to deliver
# files (assuming that the underlying OS supports it).
# The default is on; turn this off if you serve from NFS-mounted
# filesystems. On some systems, turning it off (regardless of
# filesystem) can improve performance; for details, please see
# core - Apache HTTP Server
#
#EnableMMAP off

#
# EnableSendfile: Control whether the sendfile kernel support is
# used to deliver files (assuming that the OS supports it).
# The default is on; turn this off if you serve from NFS-mounted
# filesystems. Please see
# core - Apache HTTP Server
#
#EnableSendfile off


#
# The following directives modify normal HTTP response behavior to
# handle known problems with browser implementations.
#
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0

#
# The following directive disables redirects on non-GET requests for
# a directory that does not include the trailing slash. This fixes a
# problem with Microsoft WebFolders which does not appropriately handle
# redirects for folders with DAV methods.
# Same deal with Apple's DAV filesystem and Gnome VFS support for DAV.
#
BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^WebDAVFS/1.[012]" redirect-carefully
BrowserMatch "^gnome-vfs" redirect-carefully

Mein System ist:
openSUSE 10.3 inkl. Plesk 8.4

Hier noch ein ps aux, wenns hilft:
/etc/apache2$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 660 280 ? Ss 11:06 0:00 init [3]
root 27718 0.0 0.0 5940 1128 ? Ss 11:06 0:00 /usr/sbin/sshd -o PidFile=/var/run/sshd.init.pid
root 27725 0.0 0.0 1592 636 ? Ss 11:06 0:00 /sbin/syslogd -a /var/lib/named/dev/log
root 27731 0.0 0.0 2236 868 ? Ss 11:06 0:00 /usr/sbin/xinetd
root 27744 0.0 0.0 3276 648 ? S 11:06 0:00 /usr/lib/courier-imap/couriertcpd -address=0 -stderrlogger=/usr/sbin/courierlogger -stderrloggername=imapd -maxprocs=40 -maxperip=4 -pid=/var/run/imapd.pid -nodnslookup -noidentlookup 143 /usr/sbin/imaplogin /usr/lib/courier-imap/authlib/authpsa /usr/bin/imapd Maildir
root 27746 0.0 0.0 3048 672 ? S 11:06 0:00 /usr/sbin/courierlogger imapd
root 27755 0.0 0.0 3276 648 ? S 11:06 0:00 /usr/lib/courier-imap/couriertcpd -address=0 -stderrlogger=/usr/sbin/courierlogger -stderrloggername=imapd-ssl -maxprocs=40 -maxperip=4 -pid=/var/run/imapd-ssl.pid -nodnslookup -noidentlookup 993 /usr/bin/couriertls -server -tcpd /usr/sbin/imaplogin /usr/lib/courier-imap/authlib/authpsa /usr/bin/imapd Maildir
root 27757 0.0 0.0 3048 672 ? S 11:06 0:00 /usr/sbin/courierlogger imapd-ssl
root 27764 0.0 0.0 3276 648 ? S 11:06 0:00 /usr/lib/courier-imap/couriertcpd -address=0 -stderrlogger=/usr/sbin/courierlogger -stderrloggername=pop3d -maxprocs=40 -maxperip=4 -pid=/var/run/pop3d.pid -nodnslookup -noidentlookup 110 /usr/sbin/pop3login /usr/lib/courier-imap/authlib/authpsa /usr/bin/pop3d Maildir
root 27766 0.0 0.0 3048 672 ? S 11:06 0:00 /usr/sbin/courierlogger pop3d
root 27774 0.0 0.0 3276 648 ? S 11:06 0:00 /usr/lib/courier-imap/couriertcpd -address=0 -stderrlogger=/usr/sbin/courierlogger -stderrloggername=pop3d-ssl -maxprocs=40 -maxperip=4 -pid=/var/run/pop3d-ssl.pid -nodnslookup -noidentlookup 995 /usr/bin/couriertls -server -tcpd /usr/sbin/pop3login /usr/lib/courier-imap/authlib/authpsa /usr/bin/pop3d Maildir
root 27776 0.0 0.0 3048 672 ? S 11:06 0:00 /usr/sbin/courierlogger pop3d-ssl
root 27784 0.0 0.0 1900 744 ? Ss 11:06 0:00 /usr/sbin/cron
named 27829 0.0 0.3 40692 6992 ? Ssl 11:06 0:00 /usr/sbin/named -t /var/lib/named -u named
root 27848 0.0 0.0 2560 1264 ? S 11:06 0:00 /bin/sh /usr/bin/mysqld_safe --mysqld=mysqld --user=mysql --pid-file=/var/lib/mysql/mysqld.pid --socket=/var/lib/mysql/mysql.sock --datadir=/var/lib/mysql
mysql 27900 0.0 0.7 117316 14652 ? Sl 11:06 0:03 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/mysqld.pid --skip-external-locking --port=3306 --socket=/var/lib/mysql/mysql.sock
qmails 27917 0.0 0.0 1564 404 ? S 11:06 0:00 qmail-send
qmaill 27919 0.0 0.0 1516 480 ? S 11:06 0:00 splogger qmail
root 27920 0.0 0.0 1544 360 ? S 11:06 0:00 qmail-lspawn | /usr/bin/deliverquota ./Maildir
qmailr 27921 0.0 0.0 1540 360 ? S 11:06 0:00 qmail-rspawn
qmailq 27922 0.0 0.0 1512 352 ? S 11:06 0:00 qmail-clean
root 27985 0.0 0.5 29400 12328 ? Ss 11:06 0:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL
wwwrun 27989 0.0 0.6 34248 14076 ? S 11:06 0:01 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL
root 28010 0.0 0.3 41440 6416 ? Ss 11:06 0:00 /usr/local/psa/admin/bin/httpsd
psaadm 28014 0.0 1.3 46980 27464 ? S 11:06 0:04 /usr/local/psa/admin/bin/httpsd
psaadm 28189 0.0 1.2 45916 26332 ? S 11:14 0:05 /usr/local/psa/admin/bin/httpsd
psaadm 28196 0.0 1.1 47136 24236 ? S 11:14 0:03 /usr/local/psa/admin/bin/httpsd
wwwrun 28214 0.0 0.6 32752 12768 ? S 11:14 0:02 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL
wwwrun 30427 0.0 0.6 34248 14056 ? S 11:51 0:01 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL
wwwrun 32080 0.0 0.6 34248 14052 ? S 12:12 0:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL
wwwrun 32081 0.1 0.6 32476 12484 ? S 12:12 0:01 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL
wwwrun 32082 0.0 0.6 34248 14032 ? S 12:12 0:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL
wwwrun 32412 0.0 0.5 32444 12356 ? S 12:23 0:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL

root 32417 0.0 0.0 5672 1800 ? Ss 12:24 0:00 /usr/lib/ssh/sftp-server
wwwrun 32638 0.0 0.3 29400 6896 ? S 12:28 0:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL
wwwrun 32639 0.0 0.6 32744 12724 ? S 12:28 0:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL
wwwrun 32644 0.1 0.6 33504 13372 ? S 12:28 0:01 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL

root 1488 0.8 0.0 4280 1716 ? Ss 12:40 0:00 -bash
root 1513 0.0 0.0 2152 860 ? R 12:40 0:00 ps aux

Vielen Dank für eure Hilfe.. Gruß Peter
 
Last edited by a moderator:
Ok, laut Support ist der Server überlastet. Da ich aber daran nichts ändern kann muss ich den Server also anders hinbekommen.
Du könntest in einen Tarif mit mehr Resourcen wechseln. Ansonsten benutze bitte die Suchfunktion des Forums. Das Thema wird regelmäßig durchgekaut.
 
@Roger
vielen Dank für deine aufschlußreiche Antwort.

Falls es doch jemanden interessiert, ich habe das Problemm wie folgt gelöst:

Ein kleines Shell Script überprüft ob der Apache läuft, wenn nicht wird der Indianer neu gestartet.
Das Script nun als Cronjob, entweder über Plesk oder eben über crontab einrichten.

Hier das Script:
#!/bin/sh
run=`ps ax | grep /usr/sbin/httpd | grep -v grep | cut -c1-5 | paste -s -`
if [ "$run" ];
then
echo "Apache is running"
else
/etc/init.d/apache2 restart
fi
Das Script mit den Pfaden ist für Suse 10.3 und Plesk 8.4 angepasst. Bei Debian müsst ihr die Pfade ändern.

PS: Es ist mir schon klar, dass wenn die Ressourcen nicht genügen, dass der Apache abschmiert. Aber es kann doch nicht sein, dass er dann nicht mehr autom. gestartet wird. Einfach ohne Worte.
 
Last edited by a moderator:
PS: Es ist mir schon klar, dass wenn die Ressourcen nicht genügen, dass der Apache abschmiert. Aber es kann doch nicht sein, dass er dann nicht mehr autom. gestartet wird. Einfach ohne Worte.
Normalerweise will man den Grund für den Absturz (in deinem Fall eben die fehlenden Resourcen) erst analysieren, bevor man den Service einfach wieder startet.

Davon abgesehen könntest du dafür ja auch den Watchdog von Plesk (eine Variante von monit) nutzen.
 
Bei Debian müsst ihr die Pfade ändern.
Wieso sollte man irgendjemandem _das_ als Lösung vorschlagen?

Aber es kann doch nicht sein, dass er dann nicht mehr autom. gestartet wird.
Doch. Das ist wie Init Daemons startet - Wenn der Daemon gestartet ist, interessiert Init sich nicht mehr dafür.

Du könntest den Daemon alternativ mit Daemontools fahren - das startet den Prozess sofort neu, falls er terminiert.
Aber das ist ebenfalls nichts, was das Wort "Lösung" verdient hätte.
 
KeepAliveTimeout 15 kannst du auf den Wert 2 ändern, da in 99% der Fälle 15 Sekunden kein geeigneter Wert ist. Apache über ein Script neu starten kann nicht die Lösung des Problems sein! Ursachenbekämpfung ist angesagt. :)

Thread zu Apache Optimierung haben wir ja einige, suche mal nach Tuning Primer.

Apache + MySQL Optimierung
 
Back
Top