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,注意系统重启之后会被复位