Replication
ℹ️ For technical support, please contact us via email.
Configure the nodes
✅ Start cqlsh
cqlsh
✅ Execute the following statements to create a keyspace with the NetworkTopologyStrategy that will store one replica per data center:
CREATE KEYSPACE killrvideo WITH replication = {
'class': 'NetworkTopologyStrategy',
'dc-seattle': 1,'dc-atlanta': 1
};
✅ Switch to the killrvideo keyspace:
Solution
USE killrvideo;
✅ Execute the following commands to re-create the videos_by_tag table and re-import the data:
CREATE TABLE videos_by_tag (
tag text,
video_id uuid,
added_date timestamp,
title text,
PRIMARY KEY ((tag), added_date, video_id))
WITH CLUSTERING ORDER BY (added_date DESC, video_id ASC);
COPY videos_by_tag(tag, video_id, added_date, title)
FROM './data-files/videos-by-tag.csv'
WITH HEADER=TRUE;
✅ Exit cqlsh
QUIT
✅ Execute the following commands to determine which nodes the partition replicas reside on:
nodetool getendpoints killrvideo videos_by_tag 'cassandra'
nodetool getendpoints killrvideo videos_by_tag 'datastax'
You’ll be able to see the replicas nodes, represented by their IP addresses.
Datacenter dc-seattle
contains 127.0.0.1
and 127.0.0.2
. Datacenter dc-atlanta
contains 127.0.0.3
.