Setup HA Cassandra Cluster
Install Cassandra
Configure cassandra node
Default config file is placed in /etc/cassandra/cassandra.yaml
Once cassandra is installed stop it and delete /var/lib/cassandra/data/*
- edit /etc/cassandra/cassandra.yaml
YAML
cluster_name: 'Test Cluster'
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
- seeds: "your-server-ip,your-server-ip-2"
listen_address: your-server-ip
rpc_address: your-server-ip
auto_bootstrap: false
Added the line in the end:
auto_bootstrap: false
Bash
sudo sed -i 's/endpoint_snitch: SimpleSnitch/endpoint_snitch: GossipingPropertyFileSnitch/g' /etc/cassandra/cassandra.yaml
Start cassandra server(s)
- Test with command
Creating keyspaces
In this case we have two cassandra nodes so create keyspaces with 2 replicas (how many nodes that many replicas so the ownership would be 100% on all nodes):
Bash
CREATE KEYSPACE IF NOT EXISTS somename WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 2} AND durable_writes = true;
If one of the nodes "dies"
remove the faulty one from working one:
Bring back new node with the same IP (of the dead one) and everything will work.