Skip to content

Files

Latest commit

Dec 15, 2023
f400df2 · Dec 15, 2023

History

History
165 lines (57 loc) · 4.43 KB

20180110_01.md

File metadata and controls

165 lines (57 loc) · 4.43 KB

PostgreSQL on Docker部署时的shm配置注意

作者

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  

相关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/

您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.

digoal's wechat