Postgresql FATAL: could not create semaphores: No space left on device 柔光的暖阳◎ 2021-11-02 10:01 224阅读 0赞 昨天安装完成pg 9.5后,启动报错: FATAL: could not create semaphores: No space left on device DETAIL: Failed system call was semget(xxxxxxxxxx). HINT: This error does \*not\* mean that you have run out of disk space. It occurs when either the system limit for the maximum number of semaphore sets (SEMMNI), or the system wide maximum number of semaphores (SEMMNS), would be exceeded. You need to raise the respective kernel parameter. Alternatively, reduce PostgreSQL's consumption of semaphores by reducing its max\_connections parameter. 查看报错日志是由于内核的相关配置参数设置过小引起的。 这里是共享内存段的限制,简单介绍一下 如果数据库报FATAL: could not create shared memory segment:Cannot allocate memory 错误,可以考虑修改以下相关参数 #ipcs -lm ------ Shared Memory Limits -------- max number of segments = 4096 max seg size (kbytes) = 67108864 max total shared memory (kbytes) = 17179869184 min seg size (bytes) = 1 #cat /proc/sys/kernel/shmmax 68719476736 SHMMAX 单个共享内存段最大字节数 # cat /proc/sys/kernel/shmmni 4096 SHMMNI 共享内存段最大个数 # cat /proc/sys/kernel/shmall 4294967296 SHMALL系统中共享内存也总数,至少为ceil(shmmax/PAGE\_SIZE) 获取page\_size值 # getconf PAGE_SIZE 4096 可以根据实际情况修改以上参数值,在/etc/sysctl.conf配置文件中 今天遇到的错误,主要解决以下参数的限制才能解决我们数据库启动的报错 # ipcs -ls ------ Semaphore Limits -------- max number of arrays = 1280 max semaphores per array = 50100 max semaphores system wide = 64128000 max ops per semop call = 50100 semaphore max value = 32767 # cat /proc/sys/kernel/sem SEMMSL SEMMNS SEMOPM SEMMNI 50100 128256000 50100 2560 SEMMSL 每个信号量set中信号量最大个数 SEMMNS linux系统中信号量最大个数 SEMOPM semop系统调用允许的信号量最大个数设置,设置成和SEMMSL一样即可 SEMMNI linux系统信号量set最大个数 所以SEMMNS=SEMMSL\*SEMMNI 所以要么增大信号量,要么减少max\_connect参数 这里我选择增大信号量 修改 vi /etc/sysctl.conf 的以下参数 kernel.sem = 50100 128256000 50100 2560 ipcs -ls \------ Semaphore Limits -------- max number of arrays = 2560 max semaphores per array = 50100 max semaphores system wide = 128256000 max ops per semop call = 50100 semaphore max value = 32767 重新启动数据库后无报错,数据库可以正常启动。 下面是官方文档中对s emaphores相关参数的说明: <table> <thead> <tr> <th>Name</th> <th>Description</th> <th>Reasonable values</th> </tr> </thead> <tbody> <tr> <td>SHMMAX</td> <td>Maximum size of shared memory segment (bytes)</td> <td>at least 1kB (more if running many copies of the server)</td> </tr> <tr> <td>SHMMIN</td> <td>Minimum size of shared memory segment (bytes)</td> <td>1</td> </tr> <tr> <td>SHMALL</td> <td>Total amount of shared memory available (bytes or pages)</td> <td>if bytes, same as SHMMAX; if pages, ceil(SHMMAX/PAGE_SIZE)</td> </tr> <tr> <td>SHMSEG</td> <td>Maximum number of shared memory segments per process</td> <td>only 1 segment is needed, but the default is much higher</td> </tr> <tr> <td>SHMMNI</td> <td>Maximum number of shared memory segments system-wide</td> <td>like SHMSEG plus room for other applications</td> </tr> <tr> <td>SEMMNI</td> <td>Maximum number of <span>semaphore</span><span>(打旗语)</span> identifiers (i.e., sets)</td> <td>at least ceil((max_connections + autovacuum_max_workers + max_worker_processes + 5) / 16)</td> </tr> <tr> <td>SEMMNS</td> <td>Maximum number of semaphores system-wide</td> <td>ceil((max_connections + autovacuum_max_workers + max_worker_processes + 5) / 16) * 17 plus room for other applications</td> </tr> <tr> <td>SEMMSL</td> <td>Maximum number of <span>semaphores</span><span>(信号)</span> per set</td> <td>at least 17</td> </tr> <tr> <td>SEMMAP</td> <td>Number of entries in semaphore map</td> <td>see text</td> </tr> <tr> <td>SEMVMX</td> <td>Maximum value of semaphore</td> <td>at least 1000 (The default is often 32767; do not change unless necessary)</td> </tr> </tbody> </table> ** ** 参考: http://blog.163.com/dazuiba\_008/blog/static/363349812016314739538/ http://www.postgresql.org/docs/9.4/static/kernel-resources.html\#SYSVIPC-PARAMETERS 转载于:https://www.cnblogs.com/xiaotengyi/p/5439231.html
还没有评论,来说两句吧...