3
votes

Does Cassandra support one direction replication? Say I have 2 DCs, DC1 and DC2. Real time data is being written only in DC1 and asynch replication happens in DC2. Is there a way now if I do some write on same data in DC2, it does not get replicated in DC1?

3

3 Answers

2
votes

There is no concept of one way replication. If your replication factor is 2 then it will replicate data in any two nodes. You are using DC1 and DC2 then you have to use the "NetworkTopologyStrategy" and define the replication factor for each DC. Your problem will automatically resolve using "Snitch" tool to decided data store in different nodes in both DC's.

1
votes

This feature is available when you create a keyspace

Let's say you want the keyspace 1 to be replicated on both datacenters and keyspace 2 on one datacenter:

This will replicate your data on one datacenter:

CREATE KEYSPACE keyspace1 WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'datacenter1' : 1 };

And this on both datacenters :

CREATE KEYSPACE keyspace2
  WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'datacenter1' : 1, 'datacenter2' : 1};
0
votes

There is no concept of one way replication. You have a few options:

1) use low consistency levels (LOCAL_*) when writing on writes to DC2 so the app doesn't block to replicate to DC1

2) keep the dcs in separate rings, and bulk load a synchronously with stable loader