Postgres-无法创建共享内存段:参数无效

Postgres-无法创建共享内存段:参数无效

Shmmax,Shmall,我就是赢不了;)

我尝试对我的/etc/sysctl.d/30-postgresql-shm.conf文件进行了一些修改,取消了注释并进行了一些更改kernel.shmmaxkernel.shmall但似乎没有帮助。

#/etc/sysctl.d/30-postgresql-shm.conf 
# Shared memory settings for PostgreSQL

# Note that if another program uses shared memory as well, you will have to
# coordinate the size settings between the two.

# Maximum size of shared memory segment in bytes
#kernel.shmmax = 33554432  # Original
#kernel.shmmax = 41943040  # Tried this (bigger)
kernel.shmmax = 943040  # and this (smaller)

# Maximum total size of shared memory in pages (normally 4096 bytes)
#kernel.shmall = 2097152  # Tried with and without this commented out

然后(错误):

$ sudo /etc/init.d/postgresql start
* Starting PostgreSQL 9.2 database server    
* The PostgreSQL server failed to start. Please check the log output:
2013-04-27 16:21:33 EDT FATAL:  could not create shared memory segment: Invalid argument
2013-04-27 16:21:33 EDT DETAIL:  Failed system call was shmget(key=5432001, size=30490624, 03600).
2013-04-27 16:21:33 EDT HINT:  
This error usually means that PostgreSQL's request for a shared memory segment  exceeded your kernel's SHMMAX parameter.  
You can either reduce the request size or reconfigure the kernel with larger SHMMAX.  
To reduce the request size (currently 30490624 bytes), reduce PostgreSQL's shared memory usage, 
perhaps by reducing shared_buffers or max_connections.
If the request size is already small, it's possible that it is less than your kernel's SHMMIN parameter,  
in which case raising the request size or reconfiguring SHMMIN is called for.
The PostgreSQL documentation contains more information about shared memory configuration.

注意:我该如何“提高请求大小”,因为这是列出的唯一我还没有尝试过的事情。

答案1

好吧,经过一番试验之后,我发现将 /etc/sysctl.conf 更改为 kernel.shmmax=89934592(比原始 kernel.shmmax=8589934592 短两位数)只是为了好玩......有效!

* Starting PostgreSQL 9.2 database server [ OK ] durrantm$

答案2

一个稍微好一点的解决方案:

  1. 为了避免在系统更新中覆盖值,请在/etc/sysctl.d/[filename].conf
  2. 设置kernel.shmmax = [size of error + 1000]. Ex 30490624 + 1000
  3. sysctl重新加载

    sysctl --system
    
  4. 使用以下方法检查新值:

    sysctl kernel.shmmax
    

答案3

对此的解决方案是,要么增加 SHMALL 的值,要么减少共享缓冲区的值

相关内容