postgresqlconfigurationmacos

Setting SHMMAX etc values on MAC OS X 10.6 for PostgreSQL


I'm trying to startup my PostgreSQL server on my local machine. But I got an error message saying:

FATAL:  could not create shared memory segment: Invalid argument
DETAIL:  Failed system call was shmget(key=5432001, size=9781248, 03600).
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 9781248 bytes), reduce PostgreSQL's shared_buffers parameter (currently 1024) and/or its max_connections parameter (currently 13).
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.  

I search and looked at the docs but everything I tries about setting the kern.sysv.shmmax and kern.sysv.shmall is working. What are the right settings on Snow Leopard? I installed postgres with macports.


Solution

  • Warning: this answer has been made obselete by newer versions of OS X. Please reference Paul Legato's answer below.

    In Mac OS X you cannot change shmmax after the system has booted. You need to edit /etc/rc or /etc/sysctl.conf, and keep in mind that it needs to be a multiple of 4096. See here http://www.postgresql.org/docs/8.4/static/kernel-resources.html