Wednesday, February 29, 2012

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

   Sometime Apache (HTTPD) service on a Server stops and while restart it shows following messages in error_logs

[Mon Jan 17 00:18:23 2011] [crit] (28)No space left on device: mod_rewrite: Parent could not create RewriteLock file /usr/local/apache/logs/rewrite_lock Configuration Failed

  Such errors appears when you are running out of Disk Space or Quota which is assigned (which can be increased to fix the issue) OR when semaphores of the server gets full. Semaphores are often used to restrict the number of threads than can access some (physical or logical) resource.

Using the below command you can semaphores list.

root@mughil:~# ipcs -s | grep nobody

  So, In-order to clear the semaphores list. We have execute the following command.

root@mughil:~# ipcs -s | grep nobody | awk '{print $2}' | xargs -n 1 ipcrm sem

  After clearing the semaphores list, restart the apache server. Now, it will starts without any issues.But, it is an temporary solution it will re-occur when Semaphores get full.

  Add following lines in “/etc/sysctl.conf” to get this issue fixed permanently. These values will increase the limits of Semaphores on the Server.

# Increases the semaphore limits & extend Apache's uptime.
kernel.msgmni = 512
kernel.sem = 250 128000 32 512

Then load the new settings into the kernel using the command.

root@mughil:~# sysctl -p

2 comments: