CouchDB, I am beginning to relax
Notes from the install on Mac OSX 10.5 Leopard
I had briefly played with a CouchDB install a few years ago, but never gave it a serious digging. My next personal project to really learn the ins and outs of CouchDB and figure out how to make it work for me. I had never tried to install couchDB before, so I figured I would take a run at it on my Mac Book. The following is what I learned and how I made it work:
The Easy Way
You will need to install MacPorts for this. The installation should be fairly straight forward the provided .dmg is the simplest way to get it up and running quickly. Once MacPorts is installed, the rest is cake— just 2 lines to and you have a running couchdb instance.
sudo port install couchdb +server
sudo -i -u couchdb couchdb
Go ahead and check the running instance at http://127.0.0.1:5984/_utils/index.html
You should be able to see an access log being dumped to the terminal. This is actually how I prefer to run it while coding so that I can see the live access log.
You could also launch it as a service by running the following command:
sudo launchctl load -w \
/usr/local/Library/LaunchDaemons/org.apache.couchdb.plist
As of today,Feb 8th 2009, this method installs version 0.81 of couchdb, but I wanted a more up to date dev version so I decided to uninstall the ports version and build it from source. Firstly, I uninstalled the ports version in order to avoid problems.
sudo port uninstall couchdb
The Not So Easy Way
Get Couch DB
The first step is to download a fresh copy of couchdb from svn
svn co http://svn.apache.org/repos/asf/couchdb/trunk couchdb
Once you get the source (cd couchdb), I would recommend popping open the README, it is hugely helpful and it is a great starting point for the installation.
Install Dependancies
You need MacPorts again.
I have seen it recommended a few places that erlang is left at the end of this list since it is usually the one that has an issue on mac osx. I have followed that advice but didn’t receive any errors when installing erlang.
port install automake autoconf libtool \
help2man icu spidermonkey curl erlang
Big Bang
Ok, here is where it all happens. In the couchdb directory run the following command, it will bootstrap, configure, make and, you guessed it, install couchdb.
./bootstrap && ./configure && make && sudo make install
The commands could each be done separately, and if you are an advanced user, that may be advisable. If you want to change come config values try ./configure --help to get a list of options.
Setting up User
http://www.macosxhints.com/article.php?story=20071025175202466
Now, this is where it got a little hairy for me. dscl is new to me and so I had to do some research to figure out how to get the couch user setup correctly.
If I just ran sudo -i -u couchdb couchdb right now, I received an error about the shell. That happens because the shell and home attributes of the couchdb user are not setup correctly.
If you run the command dscl . -read /Users/couchdb and you get a eDSRecordNotFound error then you first need to create a user either by using the System Preferences > Accounts route or using dscl (more details on creating a user using dscl) which I won’t go into more detail about here.
When you look at the details of the couchdb user they should look something like this:
AppleMetaNodeLocation: /Local/Default
GeneratedUID: C90A5B9A-52DE-4DCA-A819-849B80398B52
NFSHomeDirectory: /usr/local/var/lib/couchdb
Password: *
PrimaryGroupID: 500
RealName: couchdb
RecordName: couchdb
RecordType: dsRecTypeStandard:Users
UniqueID: 500
UserShell: /bin/bash
The two very important parts are that there is a UserShell set to a shell and that it is not set to /dev/null and that the NFSHomeDirectory is set to /usr/local/var/lib/couchdb. I found the easiest way to change these was to actually log in to the dscl console using the following commands:
sudo dscl localhost
cd /Local/Default/Users
Once you are in the dscl console and in the Users dir, you can run cat couchdb which will print the current settings for user couchdb.
change couchdb dsAttrTypeNative:home \
/dev/null /usr/local/var/lib/couchdb
change couchdb dsAttrTypeNative:shell \
/dev/null /bin/bash
Now that the user is set up, you just need to change the ownership of the couchdb files.
sudo chown -R couchdb:couchdb /usr/local/var/lib/couchdb
sudo chown -R couchdb:couchdb /usr/local/var/log/couchdb
Running CouchDB
Now that CouchDB is installed and the couchdb user is created, it is time to run your brand new shiny CouchDB Database.
To run it from the terminal with the access logs being printed just run the couchdb command.
sudo -i -u couchdb couchdb
If you would like to run it as a service, use the launchctl command.
sudo launchctl load \
/usr/local/Library/LaunchDaemons/org.apache.couchdb.plist
Credit
Here are some of the sites/pages I used as reference for this.
Go
Ok, now that CouchDB is installed, go and do cool stuff. Here are some links.