shmget 返回 -1, Invalid argument

来源:互联网 发布:计量型数据定义 编辑:程序博客网 时间:2024/05/20 17:06

man shmget 中明确说明:

 EINVAL A new segment was to be created and size < SHMMIN or size > SHMMAX, or no new segment was to be created,  a  segment  with  given  key
              existed, but size is greater than the size of that segment.

即kernel.shmmax的值设置太小,将导致创建共享内存失败

检查当前SHMMIN & SHMMAX :

sysctl -a | grepshmm

kernel.shmmax = 33554432
kernel.shmmni = 4096
实际请求size为:134217728 > kernel.shmmax, 所以请求失败。

修改/proc/sys/kernel/shmmax参数:
echo 1073741824 >/proc/sys/kernel/shmmax,注意系统重启之后会被复位


/etc/sysctl.conf内添加kernel.shmmax = 1073741824,在系统重启之后生效



原创粉丝点击