Steps to resolve the error “semget: No space left on device”

If apache does not start , then please check the error logs with cpanel. The error

“semget: No space left on device” shows that that your server has run out of semaphores.

If there is no problem with disk space, you need to verify the logs with

tail -f /usr/local/apache/logs/error_logs

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

To check how many semaphores are being used, login to your server as root and run the following:

ipcs –s

Output 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

then restart Apache service
/etc/init.d/httpd restart

Now to bring up the Apache service again, one has to clear the semaphores.

And for that execute the following command:

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

Above command may not work with old servers. In that case, you have to do the following :

/sbin/service httpd stop

ipcs -s | grep nobody | gawk ‘{ print $2 }’ | xargs -n 1 ipcrm sem

/sbin/service httpd start

If this is a common issue occurring , you may want to increase the semaphore limits on your hosting server.

You can do that by adding the following to the /etc/sysctl.conf file:

# For increasing the semaphore limits & extend Apache’s uptime:

kernel.msgmni = 512
kernel.sem = 250 128000 32 512

Later on a user can load the new settings into the kernel:

sysctl -p

That’s it

kbadmin has written 146 articles

Loading Facebook Comments ...

This site uses Akismet to reduce spam. Learn how your comment data is processed.