Postgresql FATAL: could not create semaphores: No space left on device

转自:http://blog.163.com/dazuiba_008/blog/static/363349812016314739538/

  今天做恢复的时候,数据库做完恢复后,无法启动报错

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

修改完成后,执行:
# sysctl -p 

使修改参数生效

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

重新启动数据库并无报错

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)

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值