Shmmax, Shmall, I just can't win ;)
I've tried changing around my /etc/sysctl.d/30-postgresql-shm.conf
file a fair bit uncommenting and changing the kernel.shmmax
and kernel.shmall
a bit but it didn't seem to help.
#/etc/sysctl.d/30-postgresql-shm.conf
# Shared memory settings for PostgreSQL
# Note that if another program uses shared memory as well, you will have to
# coordinate the size settings between the two.
# Maximum size of shared memory segment in bytes
#kernel.shmmax = 33554432 # Original
#kernel.shmmax = 41943040 # Tried this (bigger)
kernel.shmmax = 943040 # and this (smaller)
# Maximum total size of shared memory in pages (normally 4096 bytes)
#kernel.shmall = 2097152 # Tried with and without this commented out
Then (the error):
$ sudo /etc/init.d/postgresql start
* Starting PostgreSQL 9.2 database server
* The PostgreSQL server failed to start. Please check the log output:
2013-04-27 16:21:33 EDT FATAL: could not create shared memory segment: Invalid argument
2013-04-27 16:21:33 EDT DETAIL: Failed system call was shmget(key=5432001, size=30490624, 03600).
2013-04-27 16:21:33 EDT HINT:
This error usually means that PostgreSQL's request for a shared memory segment exceeded your kernel's SHMMAX parameter.
You can either reduce the request size or reconfigure the kernel with larger SHMMAX.
To reduce the request size (currently 30490624 bytes), reduce PostgreSQL's shared memory usage,
perhaps by reducing shared_buffers or max_connections.
If the request size is already small, it's possible that it is less than your kernel's SHMMIN parameter,
in which case raising the request size or reconfiguring SHMMIN is called for.
The PostgreSQL documentation contains more information about shared memory configuration.
Note: How would I 'raise the request size' as that is the only thing I haven't tried that was listed.
Well after experimenting a fair bit I found changing /etc/sysctl.conf to have kernel.shmmax=89934592 (two digits shorter than the original kernel.shmmax=8589934592) just for kicks... worked!
A slightly better solution:
/etc/sysctl.d/[filename].conf
kernel.shmmax = [size of error + 1000]
. Ex 30490624 + 1000Reload
sysctl
withCheck new value with:
For this the solution is either we need to increase the value of SHMALL or decrease the value of shared buffers