Tuesday, April 2, 2013

Installing multiple PostgreSQL versions on Homebrew

I was going to post this yesterday, but some might have thought that it was a joke. April 1st is always an annoying day to communicate real information.

If you have been fond of the way Debian and Ubuntu manage multiple PostgreSQL versions in parallel, you can now have the same on OS X with Homebrew:

brew tap petere/postgresql
brew install postgresql-9.2
# etc.
brew install --HEAD postgresql-common

postgresql-common is the same code as in Debian, only mangled a little.

Now you have all the client programs symlinked through pg_wrapper, and you can use the server management tools such as:

pg_createcluster 9.2 main
pg_ctlcluster 9.2 main start
pg_lsclusters

Let me know if you find this useful.

Links:

5 comments:

  1. You probably forgot the "brew tap" command.

    ReplyDelete
  2. First, thanks so much for the work on these tools.

    I've installed two versions of postgres via brew - 9.1 and 9.3; then installed postgresql-common. Built clusters as expected PGCLUSTER=9.1/foo; PGCLUSTER=9.1/bar. However, when I execute psql against these, the client is in 9.3 with the server in 9.1:
    09:21:40 ~$ PGCLUSTER=9.1/foo psql postgres
    psql (9.3.5, server 9.1.14)

    Tried various incarnations of linking pg_wrapper to the psql in the 9.1/bin folder, did not make a difference. Wondering if the postgresql-common is predisposed to use the latest version of postgres available in brew? If not, what magic can I use to get the server and client versions to align.

    Thanks in advance.

    ReplyDelete
    Replies
    1. postgresql-common always selects the latest psql by default, per https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=639108 .

      Delete
  3. How would one go about installing postgis in this setup? The postgis brews require one of the main postgresql brews, which conflict with the postgresql-common install. (Sorry if this is a duplicate comment - it wasn't clear if it submitted the first time I tried)

    ReplyDelete
    Replies
    1. I recommend using Pex: https://github.com/petere/pex

      Delete