digoal
2018-01-10
PostgreSQL , 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
src/backend/storage/ipc/dsm_impl.c
--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://docs.docker.com/engine/reference/run/
您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.