Fix Apache – No space left on device: Couldn’t create accept lock

Tuesday, June 23rd, 2009

This issue is related to semaphores. To view how many semaphores you have use:

root@hal [~]# sysctl -a | egrep kernel.sem\|kernel.msgmni
kernel.sem = 250 32000 32 128
kernel.msgmni = 16

You can change this values by adding them in /etc/sysctl.conf and then using sysctl -p to activate them.
There is no need to reboot.

To remove sempahores use either one of these commands:

for i in `ipcs -s | grep nobody | awk ‘{print $2}’`; do ipcrm -s $i; done
/scripts/restartsrv_httpd

or in Perl

ipcs -s | grep nobody | perl -e ‘while () { @a=split(/\s+/); print `ipcrm sem $a[1]`}’

or with xargs

ipcs -s | grep nobody | awk ‘ { print $2 } ‘ | xargs ipcrm

or bash style

for ipsemId in $(ipcs -s | grep nobody | cut -f 2 -d ‘ ‘); do ipcrm $ipsemId;done

Other errors :

Cannot create SSLMutex

add in httpd.conf

SSLMutex sem

Script to autorestart httpd server if it fails

Thursday, June 18th, 2009

I use this script on a cpanel server..if output of pgrep command is 0 then the $restart command is issued

#!/bin/bash
restart=”/scripts/restartsrv_httpd”
pgrep httpd || $restart
exit 0

If its a VPS then I might add to clear the Semaphore Arrays.

for i in `ipcs -s | grep nobody | awk ‘{print $2}’`; do ipcrm -s $i; done

Then I put this script into Cron to run every 5 minutes.

# MIN HOUR DAYOFMONTH MONTH DAYOFWEEK COMMAND
*/5 * * * * /root/checkhttp.sh