【问题标题】:Initdb for PostgreSql gives shmget errorPostgreSql 的 Initdb 给出 shmget 错误
【发布时间】:2013-09-06 00:36:49
【问题描述】:

我正在从 Win 迁移到 Mac,并通过 Homebrew 在 Mac X 10.8.3 上安装 PostgreSql 9.2.4

当我运行 initdb 命令时

initdb /usr/local/var/postgres -E utf8

我收到以下错误

DETAIL:  Failed system call was shmget(key=1, size=2072576, 03600).
HINT:  This error usually means that PostgreSQL's request for a shared memory segment exceeded 
available memory or swap space, or exceeded your kernel's SHMALL parameter.  You can either 
reduce the request size or reconfigure the kernel with larger SHMALL.  To reduce the request 
size (currently 2072576 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing 
shared_buffers or max_connections.

在研究中我发现了这个帖子

Setting SHMMAX etc values on MAC OS X 10.6 for PostgreSQL

我想我会增加 shmall,希望这会有所帮助,但我得到与上面相同的错误,下面的配置。

我的 /etc/sysctl.conf 文件的内容是

kern.sysv.shmmax=33554432
kern.sysv.shmmin=1
kern.sysv.shmmni=256
kern.sysv.shmseg=64
kern.sysv.shmall=8192

假设 shmall 是 4096 块,我似乎有足够的内存用于 shmget,除非我的系统的其他部分正在使用它。活动监视器显示我还有超过 6GB 的可用内存。

也许我在这里缺少一些基本的东西。

感谢您的帮助。

-S

【问题讨论】:

    标签: macos postgresql shared-memory


    【解决方案1】:

    使用ipcs -m 命令可以了解shmmax33554432 字节)中已经使用了多少共享内存。

    大概接近最大值。如果 shmmax 太小,未使用的 6GB 也无济于事。

    就我个人而言,我不会为这么小的值而烦恼。将shmmax 增加到 4Gb,shmall 增加到相应的 100 万。拥有高价值并没有任何实际的缺点。

    【讨论】:

    • 我按照 Daniel 的建议将 shmmax 和 shmall 增加到 4G 和 100 万,这解决了问题。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-05
    • 2018-04-04
    • 1970-01-01
    • 1970-01-01
    • 2013-01-20
    相关资源
    最近更新 更多