postgresql 共享内存设置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12616935/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
postgresql shared memory settings
提问by shutyaev
Hi all!
大家好!
We have at present the following parameters related to shared memory:
目前我们有以下与共享内存相关的参数:
postgres
postgres
shared_buffers = 7GB
max_connections = 1 500
max_locks_per_transaction = 1 024
max_prepared_transactions = 0 (not set)
system
系统
SHMALL = 2 097 152
SHMMAX = 17 670 512 640
SHMMNI = 4096
The amount of RAM is 24 693 176k
RAM 量为 24 693 176k
We need to increase max_connectionsto 3 000. When we tried to do this, we got an error
我们需要将max_connections增加到 3 000。当我们尝试这样做时,出现错误
[1-1] FATAL: could not create shared memory segment: No space left on device
[2-1] DETAIL: Failed system call was shmget(key=5432001, size=8964661248, 03600)
[3-1] HINT: This error does *not* mean that you have run out of disk space.
It occurs either if all available shared memory IDs have been taken, in which
case you need to raise the SHMMNI parameter in your kernel, or because the
system's overall limit for shared memory has been reached. If you cannot
increase the shared memory limit, reduce PostgreSQL's shared memory request
(currently 8964661248 bytes), perhaps by reducing shared_buffers or
max_connections.
The PostgreSQL documentation contains more information about shared memory
configuration.
The hint proposes to increase SHMMNIkernel parameter, but I'm not sure about how much to add :) Also, I believe that all these parameters correlate somehow, so do we need to change any other parameters accordingly?
提示建议增加SHMMNI内核参数,但我不确定要添加多少:) 另外,我相信所有这些参数都以某种方式相关,所以我们是否需要相应地更改任何其他参数?
Thanks in advance,
提前致谢,
Alexander
亚历山大
回答by Daniel Vérité
Increasing SHMMNI
will not help, it's the second part of the hint that matters here.
增加SHMMNI
无济于事,这是这里重要提示的第二部分。
Get your system's page size with the shell command getconf PAGE_SIZE
.
Usually it's 4096. Multiply that by SHMALL
.
使用 shell 命令获取系统的页面大小getconf PAGE_SIZE
。
通常是 4096。乘以SHMALL
。
In your case that should be 2097152 * 4096 = 8589934592, which is exactly 8Gb.
That's your current maximum shared memory, independently of SHMMNI
.
在您的情况下,应该是 2097152 * 4096 = 8589934592,正好是 8Gb。这是您当前的最大共享内存,与SHMMNI
.
PostgreSQL error message indicates that it needs a bit more than that.
PostgreSQL 错误消息表明它需要更多。
Conclusion: increase SHMALL
.
结论:增加SHMALL
。