Use the "System V IPC Parameters" table in "Managing Kernel Resources" in the PostgreSQL Documentation for the relationship between configuration parameters and kernel parameters, as well as calculation formulas.
Refer to the "Managing Kernel Resources" in the PostgreSQL Documentation to calculate shared memory usage.
For multiple instances, the kernel parameters should be evaluated for all instances. For example, in the case of the maximum number of shared memory segments for the entire system (SHMMNI), the total number of segments obtained by all instances should be added to the kernel parameters. In the case of the maximum number of semaphores for each process (SEMMSL), the largest of all sizes obtained by all instances should be compared to the current value prior to configuring the settings.
Note
If there is insufficient shared memory due to miscalculation of SHMMAX, a message will be output indicating that the shmget system call failed at "errno=22 (EINVAL)". Review the calculation, and reconfigure.
The relationship between System V IPC parameters and kernel parameters in various operating systems is shown below.
System | V IPC parameter | Kernel parameter action |
---|---|---|
SHMMAX | kernel.shmmax | If currentValue < calculatedValue, configure the calculated value |
SHMMIN | No compatible parameter | |
SHMALL | kernel.shmall | Specify currentValue + calculatedValue |
SHMSEG | No compatible parameter | |
SHMMNI | kernel.shmmni | Specify currentValue + calculatedValue |
SEMMNI | Fourth parameter of kernel.sem | Specify currentValue + calculatedValue |
SEMMNS | Second parameter of kernel.sem | Specify currentValue + calculatedValue |
SEMMSL | First parameter of kernel.sem | If currentValue < calculatedValue, configure the calculated value |
SEMMAP | No compatible parameter | |
SEMVMX | No compatible parameter |
Remark 1: kernel.shmall specifies the number of pages.
Remark 2: Specify all four parameters for kernel.sem. At this time, the value specified in the third parameter should be the same value as before configuration.