Vincenzo Melandri
Vincenzo Melandri

Reputation: 81

Cassandra cluster, wants to replicate across some datacenters but not all

I am looking at documentation but I can't find how to do what I need. I need to set up Apache Cassandra (not datastax, and for now I only have one test cluster) for the following scenario:

I need 1 cluster spanning 4 datacenters (some might be physical datacenters in different geographical locations, some might be AWS).

In this cluster, I need 3 keyspace. One keyspace replicates across all datacenters, the remaining keyspace need to only replicate to 1 datacenter.

+---------------------------------------------------+
|    DC 1    |    DC 2    |    DC 3    |    DC 4    |
+---------------------------------------------------+
| Keyspace A | Keyspace A | Keyspace A | Keyspace A | 
+---------------------------------------------------+
|            |            | Keyspace B | Keyspace B | 
+---------------------------------------------------+
| Keyspace C | Keyspace C |            |            | 
+---------------------------------------------------+

The reason is that data in KeyspaceB and KeyspaceC by legal obligation have to be kept in different regions. Can I get away with one cluster configuring replication factor 0 or something for the empty spaces in the above table or do I need 3 different clusters?

Cheer, Vince.

Upvotes: 3

Views: 369

Answers (1)

Vincenzo Melandri
Vincenzo Melandri

Reputation: 81

Actually, I found out.

http://docs.datastax.com/en/cassandra/3.0/cassandra/operations/opsChangeKSStrategy.html

It is possible to restrict the replication of a keyspace to selected datacenters, or a single datacenter. To do this, use the NetworkTopologyStrategy and set the replication factors of the excluded datacenters to 0 (zero), as in the following example:

cqlsh> ALTER KEYSPACE cycling WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'DC1' : 0, 'DC2' : 3, 'DC3' : 0 };

Upvotes: 3

Related Questions