PostgreSQL memory size

I’m making a fresh OSX installation. After installing PostgreSQL using homebrew, the service cannot startup intermittently. The PostgreSQL server log says

FATAL:  could not create shared memory segment: Cannot allocate memory
DETAIL:  Failed system call was shmget(key=5432001, size=3809280, 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 3809280 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.

Straight forward stuff, modify or create /etc/sysctl.conf and toss in the following

kern.sysv.shmmax=16777216
kern.sysv.shmmin=1
kern.sysv.shmmni=32
kern.sysv.shmseg=8
kern.sysv.shmall=65536

Apparently I have done this before from my previous OSX installations… Next time will be easier with this note jotted down here.

Published: 2012-11-10
blog comments powered by Disqus