dockercassandrareplication

Cassandra cluster using docker


I'm new to cassandra and wanted to understand and implement the NetworkTopology Stratergy.

I want to create a cassandra cluster with NetworkTopology stratergy with multiple data centers. How to do it?

I tried creating a docker bridge network and three cassandra nodes: cas1, cas2, cas3. When used nodetools to check status a cluster with single datacentre is only getting created. But I want to create 2 datacenters.


Solution

  • There's a document which walks you through this: Initializing a multiple node cluster (multiple datacenters). It's for Cassandra 3.x, but the procedure is pretty much the same for 4.x as well.

    But if I had to guess, I'd say there's two things you're probably missing:

    In the cassandra.yaml set the endpoint_snitch to GossipingPropertyFileSnitch.

    endpoint_snitch: GossipingPropertyFileSnitch
    

    That tells Cassandra to check the cassandra-rackdc.properties file for data center and rack information. Inside that file, you'll find the following settings (by default).

    dc=dc1
    rack=rack1
    

    This is where you can set the name of the new DC. Then you can use those data center names to specify replication on keyspaces using NetworkTopologyStrategy.