On RHEL servers, changing the semaphore value fails with a message “setting key “kernel.sem“: Numeri

在Red Hat Enterprise Linux 7.8和8.1中,尝试将SEMMNI参数值设置超过32768会失败,因为出现了'Numerical result out of range'错误。这是由于上游的改动,现在SEMMNI的最大限制被设置为32768。要超过这个限制,可以在RHEL7中通过在GRUB_CMDLINE_LINUX中添加'ipcmni_extend'参数并重启来实现。对于RHEL8,可以通过grub2-editenv编辑GRUB启动参数,无需重建GRUB。更新系统并使用'ipcmni_extend'参数后,可以成功设置大于32768的值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

环境

  • Red Hat Enterprise Linux 7.8

    • starting with kernel version 3.10.0-1127.el7.x86_64
  • Red Hat Enterprise Linux 8.1

    • starting with kernel version 4.18.0-147.el8_1.x86_64

问题

  • On RHEL 7.8 and 8.1 servers, setting the value of semaphore parameter SEMMNI beyond 32768 fails with the error message sysctl: setting key "kernel.sem": Numerical result out of range.

Raw

# sysctl -w kernel.sem="4096 2048000 32 32769"
sysctl: setting key "kernel.sem": Numerical result out of range
kernel.sem = 4096 2048000 32 32769
  • Anything up to and including 32768 succeeds :

Raw

# sysctl -w kernel.sem="4096 2048000 32 32768"
kernel.sem = 4096 2048000 32 32768
  • This also applies to kernel.msgmni and kernel.shmmni

决议

  • The change in SEMMNI behaviour is a recent change and expected behaviour that has been backported to the RHEL kernel.

  • Now, the maximum limit of SEMMNI has been set to 32768.

  • It is still possible to go beyond this limit by booting the server with the kernel command line parameter ipcmni_extend.

For RHEL 7:

  • Add this parameter ipcmni_extend in kernel commandline and reboot for changes to get reflected.

  • Below are the steps:

  • At the end of "GRUB_CMDLINE_LINUX" in "/etc/default/grub" and then save and exit the file.

Raw

# cat /etc/default/grub 
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap console=tty0 console=ttyS0,115200 ipcmni_extend"<--
GRUB_DISABLE_RECOVERY="true"
  • Rebuild the grub.

Raw

for BIOS:
# grub2-mkconfig -o /boot/grub2/grub.cfg 

for UEFI:
# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
  • Reboot the system for changes to get reflected.

  • Once the changes are done, it will be possible to set the value to greater than 32768.

Raw

# sysctl -w kernel.sem="4096 2048000 32 32769"
kernel.sem = 4096 2048000 32 32769

For RHEL 8:

  • Use grub2-editenv to edit the grub :

Raw

# grub2-editenv - set "kernelopts=root=UUID=XXXX [........] ipcmni_extend"
  • Reboot the server for changes to get reflected.

  • Note: There is no need to rebuild the grub on RHEL 8.

根源

  • The upstream commits that introduced the change are 6730e658017 and 8c81ddd2acd.

  • These commits have been backported to RHEL in commits 5523711052c and e3ea54f485a.

  • The commit states :

Raw

        ipc: IPCMNI limit check for msgmni and shmmni

        Patch series "ipc: IPCMNI limit check for *mni & increase that limit", v9.

        The sysctl parameters msgmni, shmmni and semmni have an inherent limit of
        IPC_MNI (32k).  However, users may not be aware of that because they can
        write a value much higher than that without getting any error or
        notification.  Reading the parameters back will show the newly written
        values which are not real.

        The real IPCMNI limit is now enforced to make sure that users won't put in
        an unrealistic value.  The first 2 patches enforce the limits.

        There are also users out there requesting increase in the IPCMNI value.
        The last 2 patches attempt to do that by using a boot kernel parameter
        "ipcmni_extend" to increase the IPCMNI limit from 32k to 8M if the users
        really want the extended value.

Additional Notes :

  • When a server with RHEL-8.0 / RHEL-7.7 or below kernel having the configured value of SHMMNI greater than 32768 will be updated
    to RHEL-8.1 / RHEL-7.8 kernel, then the value of SHMMNI will fall back to default 4096.
  • Similarly when a server with RHEL-8.0 / RHEL-7.7 or below kernel having the configured value of MSGMNI greater than 32768 will be updated
    to RHEL-8.1 / RHEL-7.8 kernel, then the value of MSGMNI will fall back to default 32000.
  • Likewise when a server with RHEL-8.0 / RHEL-7.7 or below kernel having the configured value of SEMMNI greater than 32768 will be updated
    to RHEL-8.1 / RHEL-7.8 kernel, then the value of SEMMNI will fall back to default 128.

诊断步骤

  • Update the RHEL 7 kernel to the 3.10.0-1127.el7.x86_64 or RHEL 8 kernel to 4.18.0-147.el8_1.x86_64. Then set the parameter value as shown below which will fail :

Raw

# sysctl -w kernel.sem="4096 2048000 32 32769"
sysctl: setting key "kernel.sem": Numerical result out of range
kernel.sem = 4096 2048000 32 32769
  • Anything up to and including 32768 will succeed :

Raw

# sysctl -w kernel.sem="4096 2048000 32 32768"
kernel.sem = 4096 2048000 32 32768
  • Boot the server with the kernel command line parameter ipcmni_extend and again set the value to 32769 which will succeed :

Raw

# sysctl -w kernel.sem="4096 2048000 32 32769"
kernel.sem = 4096 2048000 32 32769

转载至https://access.redhat.com/solutions/4968021

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值