Cassandra in a Container on OSX
Getting Your Laptop Setup
Let’s get Cassandra running, using containers to keep the runtime environment similar to what it would be in production. We are focusing on OSX only and will use a few tools that are freely available to make it all work.
-
Install Brew
-
Install CaskRoom
- Install Docker Toolbox but with brew/caskroom
- Install cqlsh so you can mess with Cassandra
5. We need git and npm too, so if you don’t already have them installed:
- Do a global install of av and the docker plugin
Launching the Container
The workflow is optimized by av-shell and the av-docker plugin that together remember multiple pieces of context so as to minimize command line arguments needed. I invite you to compare against the docker.com’s Build your own image instructions.
- Get the ‘cassandra-container’ code from github
- Get the domain specific shell up
- Make sure the virtual machine that runs docker server is running
You should see column headings but no containers.
- Now choose which container we will work with (this project has only one) with:
Use the arrow keys to select cassandra-1.2
- Now build the container
This reads the Dockerfile which has been setup to install java and cassandra.
- Now start the container with
This reads the Runfile with specifics to map OSX directories to the container
- Confirm the container is running
You should see something like this:
Optionally, you can shell into the last started container with just:
8. In a new terminal, lets login to the running container
We are using an updated cqlsh installed locally to connect with Cassandra 1.2.19 but nowadays a current version of Cassandra is 3.0 so we need to set a compatible ‘cqlversion’. You should see something like this:
Wrap-up
The Dockerfile must have a line that sets the user id of the ‘cassandra’ user to that of the docker server so that storage can be passed from OSX through to the container.
This only works for Cassandra 1.2.X as 2.0 introduced hardlinks to the filesystem and that doesn’t work with Virtualbox. Hopefully more to come on that front.