您的位置:首页 > 数据库

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

2018-01-17 09:21 441 查看
转自: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

重新启动数据库并无报错

NameDescriptionReasonable values
SHMMAXMaximum size of shared memory segment (bytes)at least 1kB (more if running many copies of the server)
SHMMINMinimum size of shared memory segment (bytes)1
SHMALLTotal amount of shared memory available (bytes or pages)if bytes, same as SHMMAX; if pages, ceil(SHMMAX/PAGE_SIZE)
SHMSEGMaximum number of shared memory segments per processonly 1 segment is needed, but the default is much higher
SHMMNIMaximum number of shared memory segments system-widelike SHMSEG plus room for other applications
SEMMNIMaximum number of semaphore identifiers (i.e., sets)at least ceil((max_connections + autovacuum_max_workers + max_worker_processes + 5) / 16)
SEMMNSMaximum number of semaphores system-wideceil((max_connections + autovacuum_max_workers + max_worker_processes + 5) / 16) * 17 plus room for other applications
SEMMSLMaximum number of semaphores per setat least 17
SEMMAPNumber of entries in semaphore mapsee text
SEMVMXMaximum value of semaphoreat least 1000 (The default is often 32767; do not change unless necessary)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐