How do I increase the number of semaphore arrays in Linux?

31,273

If you read the manpage for semget, in the Notes section you'll notice:

System wide maximum number of semaphore sets: policy dependent (on Linux, this limit can be read and modified via the fourth field of /proc/sys/kernel/sem).

On my system, cat /proc/sys/kernel/sem reports:

250 32000   32  128

So do that on your system, and then echo it back after increasing the last number:

printf '250\t32000\t32\t200' >/proc/sys/kernel/sem

(There are tab characters between the numbers, so I'm using printf to generate them.)

Share:
31,273

Related videos on Youtube

Daniel C. Sobral
Author by

Daniel C. Sobral

Updated on September 18, 2022

Comments

  • Daniel C. Sobral
    Daniel C. Sobral over 1 year

    In a Debian lenny server running postgresql, I noticed that a lack of semaphore arrays is preventing Apache from starting up.

    Looking at the limits, I see 128 arrays used out of 128 arrays maximum, for semaphores. I know this is the problem because it happens on a semget call.

    How do I increase the number of arrays?

    PS: I need Apache running to make use of phppgadmin.

    • Admin
      Admin almost 13 years
      I'm kind of surprised you managed to hit that limit -- I run apache and pgsql on multiple servers at my workplace without encountering that limit. One thing that might be of help is that phppgadmin doesn't necessarily need to run on the same server as postgresql...
    • Admin
      Admin almost 13 years
      @Shadur I suspect there are lost semaphores from early crashes. I can't do anything about that at the moment, though, so I'm considering my other options.
    • Admin
      Admin almost 13 years
      In that case I recommend you find some way to clear the lost semaphores and find out what keeps crashing, or raising the limit will just get you in trouble again when the new limit is reached...
    • Admin
      Admin over 9 years
      You can RECOMPILE, the Linux OS, and increase the hard limit. I bumped it up to thousands, because that's what I was using for one client (they were porting unix code to linux).. norman.