Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cassandra: How to identify and list the nodes that contain a particular row (replica)?

Tags:

cassandra

Setup information: I have two DataCenters with 5 nodes in each DC.

I understand that each row inserted on to a table is stored based on the data partitioning scheme used; generates the necessary replicas and stores them on other nodes (chooses nodes based on replication strategy) in the cluster. Given a row, is there a way I can find and list all the nodes that contain this row/replica ?

Thanks

Chethan

like image 734
Chethan Suresh Avatar asked Jun 19 '13 21:06

Chethan Suresh


People also ask

How do you check which nodes are down in Cassandra?

Check the status of the Cassandra nodes in your cluster - Go to the /<Install_Dir>/apache-cassandra/bin/ directory and type the ./nodetool status command. If the status for all the nodes shows as UN , then the nodes are up and running. If the status for any node shows as DN , then that particular node is down.

How do you find the replication factor in Cassandra?

If you want to look at the replication factor of a given keyspace, simply execute SELECT * FROM system_schema. keyspaces; and it will print all replication information you need.

How does Cassandra determine which node in a ring receives which data?

The partitioner determines how data is distributed across the nodes in a Cassandra cluster. Basically, a partitioner is a hash function to determine the token value by hashing the partition key of a row's data. Then, this partition key token is used to determine and distribute the row data within the ring.

Which node a row gets stored is decided by in Cassandra?

The composite key consists of a partition key, plus an optional set of clustering columns. The partition key is used to determine the nodes on which rows are stored and can itself consist of multiple columns. The clustering columns are used to control how data is sorted for storage within a partition.


1 Answers

run this on one of the cassandra nodes:

nodetool -h localhost getendpoints  <keyspace> <cf> <key>

to print the end points that owns the key

like image 149
Schildmeijer Avatar answered Oct 03 '22 14:10

Schildmeijer