ABHIONLINUX
Site useful for linux administration and web hosting

Showing posts with label semaphore. Show all posts
Showing posts with label semaphore. Show all posts

2010/04/10

Semaphore issue - Unable to start apache.

Semaphores are used for communicating between the active processes of a certain application. In the case of Apache, they're used to communicate between the parent and child processes. If Apache can't write these things down, then it can't communicate properly with all of the processes it starts.
I'd assume if you're reading this article, Apache has stopped running. Run this command as root
# ipcs -s


If you see a list of semaphores, Apache has not cleaned up after itself, and some semaphores are stuck. Clear them out with this command:
# for i in `ipcs -s | awk '/httpd/ {print $2}'`; do (ipcrm -s $i); done
Now, in almost all cases, Apache should start properly.  If it doesn't, 
you may just be completely out of available semaphores.  You may want to
 increase your available semaphores, and you'll need to tickle your 
kernel to do so.  Add this to /etc/sysctl.conf:
kernel.msgmni = 1024
kernel.sem = 250 256000 32 1024
And then run sysctl -p to pick up the new changes.

2010/01/20

Unable to start apache " pid file /usr/local/apache/logs/httpd.pid overwritten — Unclean shutdown of previous Apache run? semget: No space left on device"

If you are unable to start apache and you are getting the error log as
[Sat Oct 10 00:11:01 2008] [warn] pid file /usr/local/apache/logs/httpd.pid overwritten — Unclean shutdown of previous Apache run?
semget: No space left on device
 
It means There is no more space left in Semaphore Arrays for Apache.
semaphore is a location in memory whose value can be tested and set by more than one process.
you can check the semaphore arrays on your server using the following command

ipcs -s

It results

------ Semaphore Arrays --------
key semid owner perms nsems
0x00000000 360448 nobody 600 1
0x00000000 393217 nobody 600 1
0x00000000 425986 nobody 600 1
0x00000000 458755 nobody 600 1
0x00000000 524292 nobody 600 1
0x00000000 1114117 nobody 600 1
0x00000000 1441798 nobody 600 1
0x00000000 3604487 nobody 600 1
0x00000000 3702792 nobody 600 1
0x00000000 3768329 nobody 600 1
0x00000000 6422538 nobody 600 1
0x00000000 7077899 nobody 600 1

If here you get big list of semaphores it means some semaphores are stuck. You can clear them out with this command:

for i in `ipcs -s | awk '/nobody/ {print $2}'`; do (ipcrm -s $i); done

 Restart apache
#/etc/init.d/httpd restart