macos - Initdb for PostgreSql 给出 shmget 错误

标签 macos postgresql shared-memory

我正在从 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 个 block ,我似乎有足够的内存用于 shmget,除非它的一堆正在被我系统的其他部分使用。事件监视器显示我还有超过 6GB 的剩余可用内存。

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

感谢您的帮助。

-S

最佳答案

使用 ipcs -m命令了解在 shmmax 中已经使用了多少共享内存(33554432 字节)。

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

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

关于macos - Initdb for PostgreSql 给出 shmget 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18581059/

相关文章:

json - PostgreSQL 9.5 - 将 NULL 与 JSON 合并时更新不起作用

sql - 同一行输出的几种情况

python - 了解 Python 3.8 中的 shared_memory

macos - 使用 letsencrypt 更新证书后 SSL 不工作

Objective-C - 检查 OS X 中的 FileVault 状态

ios - iTunes 连接,Xcode 在管理器中验证

c++ - 共享内存执行得这么快?

swift - 在 web View 中加载 url 的 MacOS 问题

java - MyBatis 解析具有多个语句的参数

c - C 中的命名共享内存问题