2

installing Postgres on my mac, I got the warning about shared memory. It referred me to the readme to change this, but it's not 100% clear to me.

By setting kern.sysv.shmall equal to kearn.sysv.shmmax i.e. (set it to 1610612736), will the shared memory now be configured correctly?

On a MacBook Pro with 2GB of RAM, the author's sysctl.conf contains:

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

Note that (kern.sysv.shmall * 4096) should be greater than or equal to
kern.sysv.shmmax. kern.sysv.shmmax must also be a multiple of 4096.
Leahcim
  • 40,649
  • 59
  • 195
  • 334

3 Answers3

2

This would certainly cover what you need to have accomplished with PostgreSQL.

I don't know if I would set SHMMAX to be 1.6GB but if you need to get it above 32MB just set SHMMAX to

kern.sysv.shmmax=67108864

the rest you can leave as is.

Karlson
  • 2,958
  • 1
  • 21
  • 48
0

I believe I had the same or similar issue as I was getting an error message when I first called initdb after installing postgresql (9.1.4). I had been following this guide.

Upon calling initdb I got:

Justins-MacBook-Air:etc justinbrown$ initdb /usr/local/var/postgres -E utf8
The files belonging to this database system will be owned by user "justinbrown".
This user must also own the server process.

The database cluster will be initialized with locale en_CA.UTF-8.
The default text search configuration will be set to "english".

creating directory /usr/local/var/postgres ... ok
creating subdirectories ... ok
selecting default max_connections ... 10
selecting default shared_buffers ... 400kB
creating configuration files ... ok
creating template1 database in /usr/local/var/postgres/base/1 ... FATAL:  could not create shared memory segment: Cannot allocate memory
DETAIL:  Failed system call was shmget(key=1, size=2138112, 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 2138112 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.
child process exited with exit code 1
initdb: removing data directory "/usr/local/var/postgres"

I eventually found an answer, copied the sysctl.conf text into my own file and then restarted (didn't work until after restart) and though I don't fully understand how, everything seems to work now.

Community
  • 1
  • 1
JustinTBrown
  • 157
  • 1
  • 10
0

taken from README file in your download/installation diretory,

!!!tested and worked.

PostgreSQL One Click Installer README

Shared Memory

PostgreSQL uses shared memory extensively for caching and inter-process communication. Unfortunately, the default configuration of Mac OS X does not allow suitable amounts of shared memory to be created to run the database server.

Before running the installation, please ensure that your system is configured to allow the use of larger amounts of shared memory. Note that this does not 'reserve' any memory so it is safe to configure much higher values than you might initially need. You can do this by editting the file /etc/sysctl.conf - e.g.

% sudo vi /etc/sysctl.conf

On a MacBook Pro with 2GB of RAM, the author's sysctl.conf contains:

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

Note that (kern.sysv.shmall * 4096) should be greater than or equal to kern.sysv.shmmax. kern.sysv.shmmax must also be a multiple of 4096.

Once you have edited (or created) the file, reboot before continuing with the installation. If you wish to check the settings currently being used by the kernel, you can use the sysctl utility:

% sysctl -a

The database server can now be installed.

For more information on PostgreSQL's use of shared memory, please see:

http://www.postgresql.org/docs/current/static/kernel-resources.html#SYSVIPC

Support

For help with this installer, please visit the forum at:

http://forums.enterprisedb.com/forums/show/9.page

For help with the packages within the installer, please visit the packages website.

Dung
  • 19,199
  • 9
  • 59
  • 54