Everything about Linux Semaphore

Semaphore in Linux plays an important role in a multiprocessing system. We need to review the semaphore status if we need to kill unwanted entries to free up the memory allocated to the server.

Semaphores are IPCs, which means Inter-Process Communication Systems used to allow different processes to communicate with each other. It is a variable or abstract data type used to control access to a common resource by multiple processes in a concurrent system such as a multiprogramming operating system.

Semaphores are used for communication between the active process of some applications such as Apache. If you are facing the following error while restarting the Apache server.

 

Error

Apache error: No space left on device: mod_rewrite: Parent could not create Rewrite Lock.

The error occurs if the semaphores memory location is not free. In most cases, the parent process dies without killing its child process properly. This causes high uptime on the server. The most common errors are shown below:

 

Error:

[crit] (28)No space left on device: mod_rewrite: Parent could not create Rewrite Lock file /usr/local/apache/logs/rewrite_lock Configuration Failed

 

Error:

[error] (28)No space left on device: Cannot create SSLMutex

 

Error:

[emerg] (28)No space left on device: Couldn’t create accept lock

[notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)

[notice] Digest: generating secret for digest authentication …

[notice] Digest: done

[warn] pid file /etc/httpd/run/httpd.pid overwritten — Unclean shutdown of previous Apache run?

[emerg] (28)No space left on device: Couldn’t create accept lock

In this cases, you need to kill the process.

 

Commands to check semaphore details

If you want to check the status of the Semaphore, you can use the following command

# ipcs -s

[root@server/]# ipcs -s

—— Semaphore Arrays ——–

key                 semid      owner      perms      nsems

0x00000000      0             root          600               1

0x00000000  32769      apache      600               1

0x00000000  65538      apache      600               1

If the Apache causing any issues with the Semaphore, you need to kill the processes with user apache or nobody to start Apache properly.

 

To kill a Semaphore process, you can use the following command:

#ipcrm -s

[root@server/]# ipcrm -s

 

To list the current Semaphore configuration details:

# ipcs -l

[root@ser94 /]# ipcs -l

—— Shared Memory Limits ——–

max number of segments = 4096

max seg size (kbytes) = 32768

max total shared memory (kbytes) = 8388608

min seg size (bytes) = 1

—— Semaphore Limits ——–

max number of arrays = 128

max semaphores per array = 250

max semaphores system wide = 32000

max ops per semop call = 32

semaphore max value = 32767

—— Messages: Limits ——–

max queues system wide = 1129

max size of message (bytes) = 8192

default max size of queue (bytes) = 16384

 

To change the Semaphore parameters

1) Open the file /etc/sysctl.conf

2) Increase the following entries

kernel.msgmni and

kernel.sem

3) Run the following command.

sysctl -p

 

If you need any further assistance please contact our support department.

 

Leave a Reply