✅ Check that all three nodes are up and running:
./node1/bin/nodetool status
✅ Use nodetool getendpoints
to determine which nodes hold the replicas for the cassandra partition tag value in the videos_by_tag table:
./node1/bin/nodetool getendpoints killrvideo videos_by_tag 'cassandra'
✅ Stop both of the replica nodes for the cassandra partition by running nodetool stopdaemon
:
Note: The way the cluster, datacenters and keyspace are organized means that the replicas will either be node1 & node3 or node2 & node3.
After shutting the replicas down either node1 or node2 will still be running.
Solution
Make sure that you only shut down two replica nodes!
Node (IP) | Shutdown command |
---|---|
127.0.0.1 |
|
127.0.0.2 |
|
127.0.0.3 |
|
Keep track of which nodes you shut down and also the node number that is still up.
✅ Start cqlsh and connect to the remaining online node:
Node (IP) | cqlsh command |
---|---|
127.0.0.1 |
|
127.0.0.2 |
|
✅ Switch to the killrvideo keyspace and set the consistency level to ANY
:
Solution
USE killrvideo;
CONSISTENCY ANY;
When a client writes with consistency ANY
, storing a hint on the coordinator node is sufficient for the write to be successful. Consistency ONE
requires that at least one successful write to a replica node - a hint is not sufficient.
✅ Execute the following INSERT statement to add a new row to the videos_by_tag table:
INSERT INTO videos_by_tag (tag, added_date, video_id, title)
VALUES ('cassandra', '2020-04-07', uuid(),
'Cassandra, Take Me Home');
The write will succeed even though both replica nodes for the cassandra partition are down! The one and only node left in the cluster stores the writes as hints for the two replica nodes until they come back online.
✅ QUIT cqlsh:
QUIT