Setting up a local 3 node Cassandra cluster on single machine

When trying to create a Cassandra cluster for a small test scenario i came across the fact that it is not possible to create a cluster in a single machine by changing ports. Since i didn't want to set it up on several machines did some digging and with some help found a workaround for this.

The workaround is to add virtual Ethernet devices to our machine and use these to configure the cluster. So first we need to create 3 ip aliases for our machine, you can use the following command to get this done. This is for a Linux machine check out the stack overflow thread to check how its done on windows here

ifconfig eth0:1 192.168.0.2
ifconfig eth0:2 192.168.0.3
ifconfig eth0:3 192.168.0.4
you can check if the aliases are created by executing 'ifconfig'.

once you have this setup all you have to do is configure the Cassandra configurations. You need to change the values of the following entries cassandra.yaml file as follows

Node 1:
- seeds: "192.168.0.2"
listen_address: 192.168.0.2
rpc_address: 192.168.0.2

Node 2:
- seeds: "192.168.0.2"
listen_address: 192.168.0.3
rpc_address: 192.168.0.3
Node 3:
- seeds: "192.168.0.2"
listen_address: 192.168.0.4
rpc_address: 192.168.0.4
once you have these configs setup all you have to do is start the Cassandra server. And it will form a 3 node cluster in a ring formation.


Comments

Popular posts from this blog

Writing Unit Tests to test JMS Queue listener code with ActiveMQ

Reading and Writing Binary files in java - Converting Endianness ( between Big-endian byte order and Little-endian byte order)

Setting up Heron Cluster with Apache Aurora Locally