PostgreSQL under OS X Mountain Lion
I am actually doing a side project which you will heard of very soon. For this project I am using Play! Framework v2 with the server side being developed in Scala. To efficiently push this new application to production, I am using the Heroku platform
While my initial thoughts were using MySQL as my relational backend, the default stack provided by Heroku made me switch to postgresql that I have barely used in the past. I attempted to set it up on my machine, but with no luck, Mountain Lion is bundling an old version (8.4) whereas I wanted the same as on the Heroku platform. My first attempt with Homebrew was quite a disaster, I never managed to correctly connect my newly created user.
After a few hours mumbling, I looked for an alternative to the
Homebrew version. Luckily, the guys at Heroku provide a neat
application Postgres.app to
drop that allows to quickly start/stop a postgresql server. My
problem was I didn't had enough connections to allow my application
to start, I was always getting this message :
remaining connection slots are reserved for non-replication
I edited the configuration file
vim "~/Library/Application Support/Postgres/var/postgresql.conf"
to bump the number of connections to a lot more (20 instead of 10) but it prevented my server to start. With a lot of file editing and restarts, I found that the limit for my machine was 11 connections.
The solution to this problem resides in a special setup of the mac
os kernel which defines the amount of shared memory a process can
allocate. To get rid of this, you can edit your
/etc/sysctl.conf file (root required) and put the
following lines (it will persist across reboots)
kern.sysv.shmall=65536 kern.sysv.shmmax=16777216Credits for this tip comes from http://ruby.zigzo.com/2012/07/07/postgresql-postgres-app-and-a-gotcha-on-mac-osx-lion/