debugsqlMinor
POSTGRESQL error Could not create shared memory segment: Cannot allocate memory
Viewed 0 times
postgresqlcannoterrorcreatesharedcouldsegmentallocatememorynot
Problem
Recently my client database has restarted and thrown the below error.
How can I resolve this issue?
FATAL: could not create shared memory segment: Cannot allocate memory
DETAIL: Failed system call was shmget(key=5433001, size=5616156672, 03600).
HINT: This error usually means that PostgreSQL's request for a shared memory segment
exceeded available memory or swap space, or exceeded your kernel's SHMALL
parameter. You can either reduce the request size or reconfigure the kernel with
larger SHMALL. To reduce the request size (currently 5616156672 bytes), reduce
PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or
max_connections.
The PostgreSQL documentation contains more information about shared memory configuration.
LOG: database system was interrupted; last known up at 2017-06-07 08:10:13 BST
FATAL: the database system is starting up
FATAL: the database system is starting upHow can I resolve this issue?
Solution
The HINT seems pretty clear,
This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory or swap space, or exceeded your kernel's SHMALL parameter. You can either reduce the request size or reconfigure the kernel with larger SHMALL. To reduce the request size (currently 5616156672 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
Redhat has really good docs on
See man
Also note the top which is great generic advice This parameter sets the total amount of shared memory pages that can be used system wide. Hence, SHMALL should always be at least ceil(shmmax/PAGE_SIZE).
This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory or swap space, or exceeded your kernel's SHMALL parameter. You can either reduce the request size or reconfigure the kernel with larger SHMALL. To reduce the request size (currently 5616156672 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
Redhat has really good docs on
SHMALL. The sysctl method is the new method.sysctl -w kernel.shmall=5616156672See man
sysctl. These changes do not persist through reboot. Pay attention to the bottom, to make the change permanent,echo "kernel.shmall=5616156672" >> /etc/sysctl.confAlso note the top which is great generic advice This parameter sets the total amount of shared memory pages that can be used system wide. Hence, SHMALL should always be at least ceil(shmmax/PAGE_SIZE).
Code Snippets
sysctl -w kernel.shmall=5616156672echo "kernel.shmall=5616156672" >> /etc/sysctl.confContext
StackExchange Database Administrators Q#176137, answer score: 3
Revisions (0)
No revisions yet.