In this post I’ll walk you through set up of the test Apache Cassandra cluster in a Docker environment. This is useful if you want to experiment with this NoSql database or need it as part of your development environment.
First of all, you need to have Docker installed on your system.
If you use it from Mac OS X, like me, then please make sure your VirtualBox VM instance has enough memory for running Cassandra cluster.
- Open “VirtualBox” app
- Find the VM, in my case it was “default”
- Open “Settings”, then “System”
- Make sure it has at least 8GB available
Now we are ready to begin the fun part.
Let’s run single Cassandra instance and then check that it is up using
docker ps command:
Note that there is
-m 2g option for
docker run command, it gives 2GB RAM
to this container. If you are curious run
docker logs cassandra1 to see log
message produced during Cassandra start up.
Connection to Cassandra instance with
cqlsh is not difficult. Just need find
out current container IP address.
To form the cluster we need to run second Cassandra container
connect it to
Ok, now we have a cluster with two instances. Let’s verify that using
nodetool status command which need to be executed inside the container.
More instances can be added to this cluster using the same approach. Before running other instances make sure that “nodetool” returns “Status=Up” for all existing cluster nodes.
I hope it was easy!