Installing Cassandra in OS X Mavericks

A step by step guide to installing Apache Cassandra database on OS X Mavericks, the hard way, as I just spent a couple of hours doing it. Hopefully, you won’t have to.

First, you need Java 7 JDK, not to be confused with JRE. Cassandra won’t run without it. So run a java -version command before you proceed.

Next, install Cassandra. You can either use the distribution from Datastax, or use a brew recipe.

I chose to use brew.   Just remember to run it as your own user (no su into another user because that would mess up starting Cassandra as a system process later.  This is speaking from experience):

brew install cassandra

After the  installation, run

brew info cassandra

This will print out the following instructions on the screen:

To reload cassandra after an upgrade:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.cassandra.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.cassandra.plist

There is probably a bug in the brew recipe for OS X Mavericks, as homebrew.mxcl.cassandra.plist was not copied to the target directory for me. It stayed in the brew install source directory, ~/usr/local/Cellar/cassandra/2.0.3, so I copied it over to ~/Library/LaunchAgents/ .

Now, take a look at homebrew.mxcl.cassandra.plist. The file reads:

<?xml version=”1.0″ encoding=”UTF-8″?>

<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “”>

<plist version=”1.0″>

















As you can see, launchctl load ~/Library/LaunchAgents/homebrew.mxcl.cassandra.plist will start cassandra using the command /usr/local/opt/cassandra/bin/cassandra and it will keep it live, which means you can’t kill the process by pid.  it will just spring back to life again and again.  To stop cassandra, use the unload option.

Now, start Cassandra. But, you haven’t got a client to verify the server is working, have you?  CQL, the Cassandra Query Language client is not installed by Homebrew as part of the server install, unlike datastax distribution.

To install CQL with Homebrew,  do:

brew install python
pip install cql

now add the cqlsh script directory to your PATH.  I add mine to .bashrc:

export PATH=/usr/local/bin/:$PATH

Finally, run cqlsh

bash-3.2$ cqlsh

Connected to Test Cluster at localhost:9160.

[cqlsh 4.1.0 | Cassandra 2.0.3 | CQL spec 3.1.1 | Thrift protocol 19.38.0]

Use HELP for help.



Next up, create your first table: