DSE Graph systemReplication
How to set the replication factor for the graph_system keyspace of a new graph.
Synopsis
system.graph('graph_name').systemReplication("{'class' : 'NetworkTopologyStrategy', 'dc1' : 3, 'dc2' : 2 }")
Description
Create a new graph and set the graph_name replication configuration using
replication()
as well as the graph_name_system configuration using
systemReplication(). Restriction: Both must be
set at the time of graph creation, because replication factor and system replication
factor cannot be altered once set for the
graph_name
and
graph_name_system
keyspaces.
DSE database settings for replication factor are
used, either SimpleStrategy
for a single datacenter or
NetworkTopologyStrategy
for multiple datacenters.
The default replication strategy for a multi-datacenter graph is
NetworkTopologyStrategy
, whereas for a single datacenter, the replication
strategy will default to SimpleStrategy
. The number of nodes will determine
the default replication factors:number of nodes per datacenter | graph_name replication factor | graph_name_system replication factor |
---|---|---|
1-3 | number of nodes per datacenter | number of nodes per datacenter |
4 | 3 | 4 |
5 or greater | 3 | 5 |
Examples
An example that creates a graph on a cluster with a two
datacenters:
system.graph('food'). replication("{'class' : 'NetworkTopologyStrategy', 'dc1' : 3, 'dc2' : 2 }"). systemReplication("{'class' : 'NetworkTopologyStrategy', 'dc1' : 3, 'dc2' : 2 }"). ifNotExists().create();The result:
==>null
shows that the graph was
successfully created. The replication settings can be verified using the
cqlsh
tool, running the
CQL DESCRIBE KEYSPACE
command: DESCRIBE KEYSPACE food;
DESCRIBE KEYSPACE food_system;with a result:
CREATE KEYSPACE food WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1: '3', 'dc2' : 2 } AND durable_writes = true;
CREATE KEYSPACE food_system WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1: '3', 'dc2' : 2 } AND durable_writes = true;