Tuesday, February 5, 2013

CouchDB +GeoCouch Installation on OS X 10.7.5

CouchDB + GeoCouch Installation on OS X 10.7.5

I am working on a mobile project that requires location data.  I originally wanted to try Couchbase Mobile but that looks like it is a ways off.  Ultimately I want to use a PaaS or a DBaaS provider for the location datastore.

Something like Cloudant or IrisCouch seems appealing but even with that I would need something local to test and develop with.  So, not wanting to hold back my momentum, I decided to use a local install of CouchDB with GeoCouch add on.  There were already a few guides on how to do this on both Macs and Linux.

Installing CouchDB

I used Mac Ports to install CouchDB.  Other instructions recommended using brew, but since I already used Mac Ports I stuck with it.

 sudo port install couchdb  

Installing GeoCouch

The Couchbase Github install instructions for GeoCouch got me part of the way there.  After following those instructions the spatial set of tests were failing.  This blog post from b.l.mak_s got me on the right track. As it turned out, the erlang beam files for GeoCouch needed to be copied to the CouchDB ebin folder and the default.ini needed updating for GeoCouch to finally work:


 sudo cp /Users/barryalexander/Development/geocouch/ebin/*  
 /opt/local/lib/couchdb/erlang/lib/couch-1.2.1/ebin/.    

The instructions in the GeoCouch Github page wanted to use an environment variable ERL_FLAGS, but I couldn't get it work, so I just copied the *.beam and couch app file to the couch db ebin folder.

Merge the contents from /opt/local/etc/couchdb/geocouch.ini to the corresponding sections in /opt/local/etc/couchdb/default.ini.  For instance, take the entries under [daemons], [httpd_db_handlers], and [httpd_design_handlers] from the geocouch.ini and move them into the default.ini of the couch installation.

After doing the above two steps, all spatial tests passed and trying the recommended smoke tests found here also worked.

 barry-alexanders-MacBook-Pro:geocouch barryalexander$ curl -X GET 'http://localhost:5984/places/_design/main/_spatial/points?bbox=0,0,180,90'  
 {"update_seq":3,"rows":[  
 {"id":"augsburg","bbox":[10.89833299999999916,48.37166700000000219,10.89833299999999916,48.37166700000000219],"geometry":{"type":"Point","coordinates":[10.89833299999999916,48.37166700000000219]},"value":["augsburg",[10.89833299999999916,48.37166700000000219]]}  
 ]}  

Of course you'll have to do this all over again if you update or reinstall couchdb.

No comments:

Post a Comment