Installing Cassandra and Thrift on Snow Leopard – A Quick Start Guide
(Updated: 2nd November for Cassandra 0.4.1)
I couldn’t find much in the way of an OS X install guide for Cassandra and (particularly) Thrift, so here’s a brief summary of the steps I took to get Cassandra up and running on Snow Leopard.
Requirements: xcode (provides java, ant and g++, autotools etc for compiling thrift) & svn.
I used macports to get “boost, “pkgconfig” and “libevent”, all used by for Thrift.
Part 1: JAVA_HOME
OSX does not set JAVA_HOME for you, instead it must be done manually.
A simple way is to add the following line to ~/.bashrc
export JAVA_HOME=$(/usr/libexec/java_home)
After setting JAVA_HOME, you will need to exit and reopen terminal before the change will take effect.
Part 2: Installing Cassandra
# I installed Cassandra into /opt and run it as me.
mkdir -p /opt/cassandra
chown -R {you} /opt/cassandra
# Need to create the log directory
mkdir -p /var/log/cassandra
chown -R {you} /var/log/cassandra
# Also Cassandra created a directory instead of a file for system.log, so...
touch /var/log/cassandra/system.log
# By default Cassandra 0.4.1 uses /var/lib for data, so...
mkdir -p /var/lib/cassandra
chown -R {you} /var/lib/cassandra
# now lets get the source
svn co https://svn.apache.org/repos/asf/incubator/cassandra/tags/cassandra-0.4.1 /opt/cassandra/cassandra-0.4.1
# If all is well you should be able to build.
cd /opt/cassandra/cassandra-0.4.1
ant
# If that works, you should be able to run cassandra
bin/cassandra -f
All going well, you should be able to, in a new terminal tab, run through the CLI tests here.
Part 3: Installing Thrift
First you’ll need boost, pkgconfig and libevent. So (using macports):
sudo port install boost
sudo port install libevent
sudo port install pkgconfig
Now, with a lack of tags and branches in SVN, I just grabbed trunk (please could someone let me know if this unwise).
svn co http://svn.apache.org/repos/asf/incubator/thrift/trunk/ /opt/cassandra/thrift
SVN revision at time of writing was 817923
Next, we build it…
(Note the /opt/local references, that’s where macports puts it’s stuff by default)
cd /opt/cassandra/thrift
./bootstrap.sh
./configure --with-boost=/opt/local --with-libevent=/opt/local --prefix=/opt/local
# If you get the error:
# ./configure: line 16440: syntax error near unexpected token `MONO,'
# ./configure: line 16440: ` PKG_CHECK_MODULES(MONO, mono >= 2.0.0, net_3_5=yes, net_3_5=no)'
# It's documented, to fix it: (assuming you installed pkgtools from macports)
ln -s /opt/local/share/aclocal/pkg.m4 /opt/cassandra/thrift/aclocal/pkg.m4
# once again:
./bootstrap.sh
./configure --with-boost=/opt/local --with-libevent=/opt/local --prefix=/opt/local
sudo make install
Language bindings
The make install should have installed libraries for ruby, perl, python etc.
EDIT: Python bindings were installed into /usr/lib/python2.6/site-packages. I had to move them to my (default apple provided python 2.6) site-packages.
If you want to install them into a virtualenv you will find the setup.py in /opt/cassandra/thrift/lib/py
Part 4: Generate “cassandra” from thrift.
Navigate to /opt/cassandra/cassandra-0.4.1/interface
and then…
thrift --gen py:new_style cassandra.thrift
This generates the cassandra python package which you can copy to your project.
If you have any suggestions for improvement here, please let me know.

Wow, great work. I was really having problems getting thrift to work – this helped a lot. It’s really frustrating to see software like thrift piled with so many build dependencies and then not have binaries available. Thanks!!!
Zach
October 12, 2009 at 1:11 am
[...] Atkinson already has a great blog post on how to get up and running with Thrift on Snow Leopard. So if that’s what you’re running, I’m going to suggest you check it out. If [...]
Using Cassandra’s Thrift interface with Ruby | Chris Chandler
October 12, 2009 at 1:47 pm
great writeup! thanks!
Jeff
October 30, 2009 at 5:01 am
[...] http://jetfar.com/installing-cassandra-and-thrift-on-snow-leopard-a-quick-start-guide/ [...]
Installing Cassandra and Thrift on OSX | Kristian Lunde
November 21, 2009 at 7:39 am