昨天安装完成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 =
max seg size (kbytes) =
max total shared memory (kbytes) =
min seg size (bytes) =
 
#cat  /proc/sys/kernel/shmmax

SHMMAX 单个共享内存段最大字节数

 
# cat  /proc/sys/kernel/shmmni

SHMMNI 共享内存段最大个数

 
# cat  /proc/sys/kernel/shmall

SHMALL系统中共享内存也总数,至少为ceil(shmmax/PAGE_SIZE)

 
获取page_size值
# getconf PAGE_SIZE

可以根据实际情况修改以上参数值,在/etc/sysctl.conf配置文件中

 今天遇到的错误,主要解决以下参数的限制才能解决我们数据库启动的报错
# ipcs -ls

------ Semaphore Limits --------
max number of arrays =
max semaphores per array =
max semaphores system wide =
max ops per semop call =
semaphore max value = # cat /proc/sys/kernel/sem
SEMMSL SEMMNS SEMOPM SEMMNI
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
 
重新启动数据库后无报错,数据库可以正常启动。
 
下面是官方文档中对semaphores相关参数的说明:
 
Name Description Reasonable values
SHMMAX Maximum size of shared memory segment (bytes) at least 1kB (more if running many copies of the server)
SHMMIN Minimum size of shared memory segment (bytes) 1
SHMALL Total amount of shared memory available (bytes or pages) if bytes, same as SHMMAX; if pages, ceil(SHMMAX/PAGE_SIZE)
SHMSEG Maximum number of shared memory segments per process only 1 segment is needed, but the default is much higher
SHMMNI Maximum number of shared memory segments system-wide like SHMSEG plus room for other applications
SEMMNI Maximum number of semaphore(打旗语) identifiers (i.e., sets) at least ceil((max_connections + autovacuum_max_workers + max_worker_processes + 5) / 16)
SEMMNS Maximum number of semaphores system-wide ceil((max_connections + autovacuum_max_workers + max_worker_processes + 5) / 16) * 17 plus room for other applications
SEMMSL Maximum number of semaphores(信号) per set at least 17
SEMMAP Number of entries in semaphore map see text
SEMVMX Maximum value of semaphore at least 1000 (The default is often 32767; do not change unless necessary)
 
 
参考:
http://blog.163.com/dazuiba_008/blog/static/363349812016314739538/
http://www.postgresql.org/docs/9.4/static/kernel-resources.html#SYSVIPC-PARAMETERS

Postgresql FATAL: could not create semaphores: No space left on device的更多相关文章

  1. postgresql 日志报错could not write to log file: No space left on device,could not write lock file "postmaster.pid": No space left on device

    今天遇到了一个特别奇怪的问题,我在用docker容器的时候,发现我的postgresql怎么也启动不起来 尝试了N多种办法,最后看了看postgresql的日志发现 postgresql 日志中报错 ...

  2. Apache: No space left on device: Couldn’t create rewrite_map(XXXX)

    启动apache的时候 有时候会遇到这样的错误:No space left on device: Couldn’t create rewrite_map(XXXX) 第一眼看以为是磁盘没有空间了,其实 ...

  3. Git异常:fatal: could not create work tree dir 'XXX': No such file or directory

    GitHub实战系列汇总:http://www.cnblogs.com/dunitian/p/5038719.html ———————————————————————————————————————— ...

  4. Git – fatal: Unable to create ‘/.git/index.lock’: File exists错误解决办法

    有时候在提交的时候,中间提交出错,导致有文件被lock,所以会报下面的错误: fatal: Unable to create ‘/msg/.git/index.lock’: File exists. ...

  5. gcc 错误:Fatal error error writing to tmp No space left on device

    在使用gcc make时报错:Fatal error error writing to tmp No space left on device finiteVolume/ddtSchemes/Eule ...

  6. mysql 无法启动的原因Can't start server: can't create PID file: No space left on device

    一大早来到公司,看到了一个噩梦,后台总是登录不上,登录就出错,还以为被黑客入侵了.经过1个小时的排错原因如下: 我的服务器是linux的,mysql的报错日志路径是/var/log/,经过查看日志发现 ...

  7. cd tom-bash: cannot create temp file for here-document: No space left on device

    Linux使用tab补全时提示 cd tom-bash: cannot create temp file for here-document: No space left on device 这是因为 ...

  8. Linux命令行报错 bash: cannot create temp file for here-document: No space left on device

    今天Linux服务器出问题了,使用"tab"补全命令时,提示 bash: cannot create temp file for here-document: No space l ...

  9. devmapper: Thin Pool has 162394 free data blocks which is less than minimum required 163840 free data blocks. Create more free space in thin pool or use dm.min_free_space option to change behavior

    问题: 制作镜像的时候报错 devmapper: Thin Pool has 162394 free data blocks which is less than minimum required 1 ...

随机推荐

  1. 2016 - 1 - 25 CSS初步 (二)

    1.The customising link We can change the link's style when we move our pointer on the link like that ...

  2. sudo: /etc/sudoers is world writable

    错误信息: sudo: /etc/sudoers is world writable sudo: no valid sudoers sources found, quitting 解决办法: 修复磁盘 ...

  3. HTML 30分钟入门教程

    作者:deerchao 转载请注明来源 本文目标 30分钟内让你明白HTML是什么,并对它有一些基本的了解.一旦入门后,你可以从网上找到更多更详细的资料来继续学习. 什么是HTML HTML是英文Hy ...

  4. FCKeditor编辑器如何使用

    转自 http://www.cnblogs.com/tylerdonet/archive/2013/04/20/3032980.html

  5. 关于eclipse中DDMS中Emulator Control选项卡为灰色不可用

    首先先感谢版主:http://blog.csdn.net/noname666/article/details/51670905#reply 方法一的出处:http://stackoverflow.co ...

  6. Lua库之时间和日期操作

    Lua库之时间和日期操作 (2010-02-07 18:41:20) 转载▼ os.time() <== 返回当前系统的日历时间os.date() <== 返回本地化的时间字符串,这里是& ...

  7. SQLALchemy(连表)、paramiko

    本节内容:

  8. CentOS7下安装MySQL5.7安装与配置(转)

    原文地址:http://www.centoscn.com/mysql/2016/0626/7537.html 安装环境:CentOS7 64位 MINI版,安装MySQL5.7 1.配置YUM源 在M ...

  9. Pixel VS Point, FrameBuffer VS RenderBuffer

    // How iOS app MVC works View, Window, AppDelegate ViewController, RootViewController // On Pixel VS ...

  10. css的初步了解

    学习了很多知识在这里,今天三月二十一日,老师讲了css的基础 对css有了初步的了解. 主要学习了以下几点: 一.css的选择器 1.派生选择器 2.类选择器 3.id选择器 4.属性选择器 二.cs ...