postgres 中的max_connection

postgres中的max_connection和mysql、oracle一样,是限制数据库服务器的最大连接数的,但是在postgres中,当max_connect设置过大,启动的时候会报错:

[postgres@localhost ~]$ FATAL:  could not create semaphores: No space left on device
DETAIL:  Failed system call was semget(1949125, 17, 03600).

创建semaphores时空间参数不够,查询官网,对这个错误有这么一段解释:

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.
The PostgreSQL documentation contains more information about configuring your system for PostgreSQL.
解决的方法是改小max_connect,当业务不允许的情况下,修改内核参数,max_connect相关的内核参数有:
Name Description Reasonable values
SHMMAX Maximum size of shared memory segment (bytes) at least several megabytes (see text)
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 + 4) / 16)
SEMMNS Maximum number of semaphores system-wide ceil((max_connections + autovacuum_max_workers + 4) / 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)
设置方法按照表格中的公式


你可能感兴趣的:(postgresql)