PostgreSql Shared Memory Error

The PostgreSQL install instructions for OS X 10.5 include a command to run to change the OS shared memory settings. Sometimes these settings seem to revert, though. If they’ve reverted or were otherwise changed you may see this big ugly error message:

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

You could dig through the docs to find the right answer, but if you want a quick fix, here’s the command sequence to run in order to get your Postgres working again.

sudo sysctl -w kern.sysv.shmall=65536
sudo sysctl -w kern.sysv.shmmax=33554432
0 Votes

1 Comment

| Leave a comment

The easiest way to make this persist is to put the following in your:

/etc/sysctl.conf

(sudo vi /etc/sysctl.conf)

kern.sysv.shmmax=1610612736
kern.sysv.shmall=393216
kern.sysv.shmmin=1
kern.sysv.shmmni=32
kern.sysv.shmseg=8
kern.maxprocperuid=512
kern.maxproc=2048

----
If the /etc/sysctl.conf file doesn't exist, then just create it. Now it'll persist across reboots.


----

Scott Mead
EnterpriseDB
PostgreSQL 24x7 Support / Consulting
www.enterprisedb.com

Leave a comment

About this Entry

This page contains a single entry by Mike Nicholson published on October 22, 2009 11:22 AM.

CouchDB cURL Reference was the previous entry in this blog.

Solairs PS Truncates Commands is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.