• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Change Kernel Semaphore Limits in CentOS/RHEL

by admin

The post explains how kernel semaphore limits can be changed in a CentOS/RHEL server.

Kernel Parameters to set semaphore limits

The kernel parameters to set the semaphore limits are:

kernel.sem = SEMMSL SEMMNS SEMOPM SEMMNI
SEMMSL - max semaphores per array
SEMMNS - max semaphores system wide
SEMOPM - max ops per semop call
SEMMNI - max number of arrays

Changing Semaphore Limits

If a limit needs to be changed there should be taken in to account that (max number of arrays)*(max semaphores per array) >= (max semaphores system-wide). No need to have more semaphores system-wide if limited by the amount of a possible number of arrays with max semaphores per it.

For example:

# sysctl -a| grep kernel.sem
kernel.sem = 250 32000 32 128

For this example, we need to increase max semaphores per array limit from 128 to 192. The max semaphores system-wide can be also increased to 48000 ( 250*192 = 48000 >= 32000) or kept as 32000. In this scenario, it is kept at 32000.

To set kernel parameter dynamically i.e. without the need for server reboot.

# sysctl -w kernel.sem="250 32000 32 192"
kernel.sem = 250 32000 32 192

If all is fine with the system as expected, modify kernel parameter by adding it to the /etc/sysctl.conf file to ensure the value persist after server reboot.

# cat /etc/sysctl.conf | grep kernel.sem
kernel.sem = 250 32000 32 192

If you choose to set it directly in the file without using the sysctl -w, you’ll need to reload the file:

# sysctl -p

You can verify limits currently set by:

# ipcs -ls
------ Semaphore Limits --------
max number of arrays = 192
max semaphores per array = 250
max semaphores system wide = 32000
max ops per semop call = 32
semaphore max value = 32767

A semaphore is like a counter used to control access to shared resources by multiple processes. It is often used as a locking mechanism to prevent processes from accessing a particular resource while another process is performing operations on it. Semaphore value can be incremented or decremented until maximum set by variable SEMVMX, “semaphore max value”.

Filed Under: CentOS/RHEL 5, CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. route: command not found
  2. RHEL 7 – RHCSA Notes – Set enforcing and permissive modes for SELinux
  3. debchange: command not found
  4. CentOS / RHEL 7 : Tips on Troubleshooting NTP / chrony Issues
  5. lxterminal Command Examples in Linux
  6. How to uninstall nvidia-cuda-toolkit software package from Ubuntu
  7. “git rev-parse” Command Examples
  8. Yum Command – RPM Based Package Management Utility
  9. lastlog Command Examples in Linux
  10. dexter: Tool for authenticating the kubectl users with OpenId Connect

You May Also Like

Primary Sidebar

Recent Posts

  • glab Command Examples
  • “glab repo” Command Examples
  • “glab release” Command Examples
  • “glab pipeline” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright