PostgreSQL settings max_connections too large to start (reprint)

Source: Internet
Author: User
Tags postgresql semaphore

This essay is reproduced from https://my.oschina.net/u/2381678/blog/552346.

The maximum number of links needs to be adjusted in the production environment PostgreSQL, but cannot be started after adjustment

The error is that the configuration of the semaphore set and semaphore in the kernel is too small. The semaphore is in the kernel, mainly to solve the inter-process synchronous, asynchronous lock problem, because each link of PostgreSQL is a process, so need more locks to use. To view the method:

These four numbers are: Semmsl,semmns,semopm,semmni

SEMMSL: The kernel parameter that controls the maximum number of signals per semaphore set.

Semmns: Core parameters, the maximum number of semaphores to be used within the control system.

The Semopm:semop () function (a kernel function, used to manipulate semaphores) is the maximum semaphore in a semaphore set that is invoked every time a lock can operate.

Semmni: The maximum number of semaphore sets in the kernel.

Semmns=semmsl*semmni

SEMOPM=SEMMSL, these two parameters are generally set to the same.

For PostgreSQL databases:

Semmni >= ceil ((max_connections + autovacuum_max_workers + 4)/16)

SEMMSL >= 17

Suppose a PG library is set up as follows:

max_connections=1000, autovacuum_max_workers = 3,

The settings for these parameters are:

Semmni = Ceil ((1000+3+4))/16) = 63, because other processes are used, generally set to 63+25=88

SEMMSL requirements greater than 17, keep the default 250

semopm=semsl=250

semmns=semmni*msmmsl=88*250=22000

In the/etc/sysctl.conf file, add:

KERNEL.SEM=250 22000 250 88

Run: sysctl-p

Make configuration effective

After the setting is complete, you can restart the operating system if you start the database or report the same error. (For what reason, I do not know, if there is any understanding of the great God, please enlighten)

PostgreSQL settings max_connections too large to start (reprint)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.