28 September 2014

Installing PostgreSQL 9.4 beta2 on Mac OS X 10.9.4 via MacPorts

After reading the blog post from EnterpriseDB about how Postgres Outperforms MongoDB, and because I have always preferred PostgreSQL to other databases, I had to check out the document handling capabilities that PostgreSQL has added recently.

Because I began using a newer computer this summer, I had not yet installed PostgreSQL. So I pulled up a previous post about installing PostgreSQL using MacPorts and did some searches to find the latest PostgreSQL. Below are the commands I ran.

First, I needed to figure out what the latest version of PostreSQL is in MacPorts:

$ sudo port search postgresql | grep '^postgresql\d\d'
postgresql80 @8.0.26 (databases)
postgresql80-doc @8.0.26 (databases)
postgresql80-server @8.0.26 (databases)
postgresql81 @8.1.23 (databases)
postgresql81-doc @8.1.23 (databases)
postgresql81-server @8.1.23 (databases)
postgresql82 @8.2.23 (databases)
postgresql82-doc @8.2.23 (databases)
postgresql82-server @8.2.23 (databases)
postgresql83 @8.3.23 (databases)
postgresql83-doc @8.3.23 (databases)
postgresql83-server @8.3.23 (databases)
postgresql84 @8.4.22 (databases)
postgresql84-doc @8.4.22 (databases)
postgresql84-server @8.4.22 (databases)
postgresql90 @9.0.18 (databases)
postgresql90-doc @9.0.18 (databases)
postgresql90-server @9.0.18 (databases)
postgresql91 @9.1.14 (databases)
postgresql91-doc @9.1.14 (databases)
postgresql91-server @9.1.14 (databases)
postgresql92 @9.2.9 (databases)
postgresql92-doc @9.2.9 (databases)
postgresql92-server @9.2.9 (databases)
postgresql93 @9.3.5 (databases)
postgresql93-doc @9.3.5 (databases)
postgresql93-server @9.3.5 (databases)
postgresql94 @9.4beta2 (databases)
postgresql94-doc @9.4beta2 (databases)
postgresql94-server @9.4beta2 (databases)
view raw gistfile1.ps1 hosted with ❤ by GitHub
This allowed me to see that PostgreSQL 9.4 beta2 is the latest version supported by MacPorts. So I embarked upon an installation of this version:
$ sudo port install postgresql94 postgresql94-server postgresql94-doc
view raw gistfile1.sh hosted with ❤ by GitHub
This install went off without a hitch, so I created a directory for the database and initialized the database:
$ sudo mkdir -p /opt/local/var/db/postgresql94/defaultdb
$ sudo chown postgres:postgres /opt/local/var/db/postgresql94/defaultdb
$ sudo su postgres -c '/opt/local/lib/postgresql94/bin/initdb -D /opt/local/var/db/postgresql94/defaultdb'
view raw gistfile1.sh hosted with ❤ by GitHub
From the ouptput of the installation, I copy/pasted the startup command and sent it to a file. I did the same for both the start and stop commands so that I have scripts to start and stop PG quickly:
$ printf '%s\n\n%s' '#!/bin/bash' 'su postgres -c "/opt/local/lib/postgresql94/bin/pg_ctl -D /opt/local/var/db/postgresql94/defaultdb -l /opt/local/var/db/postgresql94/defaultdb/postgresql.log start"' > ~/bin/pg_start.sh
$ chmod +x ~/bin/pg_start.sh
$ printf '%s\n\n%s' '#!/bin/bash' 'sudo su postgres -c "/opt/local/lib/postgresql94/bin/pg_ctl -D /opt/local/var/db/postgresql94/defaultdb stop"' > ~/bin/pg_stop.sh
$ chmod +x ~/bin/pg_stop.sh
view raw gistfile1.sh hosted with ❤ by GitHub
After starting up PG for the first time, I opened another terminal in another tab to watch the log file to see if the database was started correctly:
$ sudo tail -f /opt/local/var/db/postgresql94/defaultdb/postgresql.log
view raw gistfile1.sh hosted with ❤ by GitHub
Then I pulled up the docs via the local install of them (file:///opt/local/share/doc/postgresql94/html/index.html) and started digging into the document database support to play around.

No comments:

Post a Comment