Mac : Installing Cassandra In Mac OS X ‘Mavericks’

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.

I used brew to install and maintain it for me😉

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” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>

<plist version=”1.0″>

<dict>

<key>KeepAlive</key>

<true/>

<key>Label</key>

<string>homebrew.mxcl.cassandra</string>

<key>ProgramArguments</key>

<array>

<string>/usr/local/opt/cassandra/bin/cassandra</string>

<string>-f</string>

</array>

<key>RunAtLoad</key>

<true>

<key>WorkingDirectory</key>

<string>/usr/local/var/lib/cassandra</string>

</dict>

</plist>

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.

cqlsh>

Success.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s