PostgreSQL on Docker部署是的shm配置注意
背景
如果你使用docker启动PG时,遇到类似这样的问题,可能你需要看看docker的/dev/shm是不是不够大。
"ERROR: could not resize shared memory segment "/PostgreSQL.388782411" to 50438144 bytes: No space left on device SQL state: 53100"
调整docker启动参数–shm-size
Thank you Thomas,
I make it work with extra setting --shm-size=1g in my docker run script.
It works with 'none' and 'sysv'--I think the issue is that technically our
environment does support 'posix', but '/dev/shm' is indeed not mounted in
the LXC container, leading to a discrepancy between what initdb decides and
what's actually possible. Thanks for your help.
Thanks,
Maciek
相关PostgreSQL代码
src/backend/storage/ipc/dsm_impl.c
相关Docker参数
--ipc="MODE" : Set the IPC mode for the container
Value Description
”” Use daemon’s default.
“none” Own private IPC namespace, with /dev/shm not mounted.
“private” Own private IPC namespace.
“shareable” Own private IPC namespace, with a possibility to share it with other containers.
“container: <_name-or-ID_>" Join another (“shareable”) container’s IPC namespace.
“host” Use the host system’s IPC namespace.
--shm-size=""
Size of /dev/shm.
The format is <number><unit>.
number must be greater than 0.
Unit is optional and can be b (bytes), k (kilobytes), m (megabytes), or g (gigabytes).
If you omit the unit, the system uses bytes.
If you omit the size entirely, the system uses 64m.
参考
https://www.postgresql.org/message-id/flat/20140612090731.GB6907%40msgid.df7cb.de#20140612090731.GB6907@msgid.df7cb.de
http://www.postgresql-archive.org/Fwd-Query-error-could-not-resize-shared-memory-segment-td5998965.html#a5999004
https://docs.docker.com/engine/reference/run/