How to Provision a Single-Node Cassandra Cluster with Chef
20 September 2014 - Chef, Cassandra, Vagrant
This article describes how you can quickly install and run a single-node Cassandra cluster with Opscode Chef in a Vagrant box.
Anybody who doesn’t know either Chef or Vagrant yet should check out their websites.
Vagrant 1.4.2 with the Berkshelf and Omnibus Vagrant plugins is installed on my local machine. Berkshelf helps you manage your cookbook dependencies without maintaining your own repo, while Omnibus keeps your Chef version in your Vagrant box up-to-date automatically. Both plugins are very handy tools and you should definitely check them out.
Because I don’t want to reinvent the wheel, my first step was to find existing cookbooks and my search uncovered the following:
- A cookbook from the Opscode community website - http://community.opscode.com/cookbooks/cassandra
- Another cookbook on Github - https://github.com/michaelklishin/cassandra-chef-cookbook
At first sight both cookbooks looked promising. The first cookbook had a decent amount of recent downloads and positive ratings. The second one was and is under continuous development.
I started testing the first cookbook, but without success. After various configuration changes I finally got a meaningful error message that the cookbook wasn’t able to download the thrift package. The resource isn’t available any more. Not good news.
If you want to try it yourself please check out my gist on Github. It includes the Vagrantfile and Berksfile.
After some research I also realised that the last update of this cookbook was released on 31st January 2012, I couldn’t find the source code on the internet and I haven’t found any useful documentation. Putting all the facts together, my enthusiasm for working with that cookbook went off the boil…
Fortunately we have an alternative cookbook, which actually is great. Installation and usage went smoothly and I was cooking on gas. Everything I had wanted could be achieved with this simple cookbook. (Below you will find the Vagrantfile and Berksfile.)
If I had to say something against it, I do have one small issue, but even that doesn’t relate directly to the cookbook itself. What it is, is that the versions of the Cookbook aren’t apparent from the repository tags, as the contributors only increase the cookbook version within the metadata.rb.
The dependency definition with Berkshelf would be clearer if we could write something like this
Who can recognise what cookbook version is hidden behind the commit id? If you can do it … you’re a genius ;)
Anyway, it doesn’t detract from the effectiveness of this cookbook.
Let us take a look at the attribute definitions. There are three important attributes that need to be defined in order to install and run Cassandra as a single-node cluster, namely listen_address,broadcast_address and rpc_address. All of them need to be set to
localhost. Otherwise the Cassandra installation would expect and search for other existing Cassandra nodes, without success.
Cassandra-chef-cookbook from michaelklishin totally works for me and I’m very happy that someone is constantly maintaining it. Keep up the good work, guys! :)