What node stores Cassandra data?

Is there any command or any way to find out what data is stored on which nodes of Cassandra?

I'm pretty new to Cassandra and haven't had much luck finding this question.

Thank!

+3


source to share


2 answers


You can get Cassandra to tell you which node a particular key is included with nodetool getendpoints .

$ nodetool getendpoints mykeyspace tbl '8546200'
192.168.73.188
192.168.73.190

      

I don't know what you are looking for or not. AFAIK there is no way to query the responsible nodes for all rows in a table or keyspace. But as Blake pointed out, your application really shouldn't worry about this.



If you really want to know, you can query your table using a function token

on your key. Here's an example using Blake's scheme:

SELECT token(partition_key),partition_key FROM tbl;

      

This would mean hashed tokens with your partition keys. You can then run nodetool ring

to list the token ranges for each node and see which nodes are responsible for that range. Please note, if you are using vNodes your output will be quite large (default 256 lines for each).

+5


source


Cassandra uses sequential hashing on the string Separating Key to determine where the data is stored. Tokens are assigned to nodes, and the negotiated hash of the section key determines where node (s) will store the string.

The section key is the first part of the PRIMARY KEY in the table definition or in nested parentheses

CREATE TABLE tbl (
partition_key INT,
clus_key TEXT,
...,
PRIMARY KEY((partition_key), clus_key);

      

Some reading here in the ring and consistent hashing. You are probably using vNodes , so I read a little here too.



During the request, you don't need to worry about what node has. Your C * driver will select a coordinator node from a list, which will find rows based on your request.

If you would like to see details of what the query is doing in CQLSH, try enabling tracing:

> TRACING ON;
> SELECT * FROM table; 

> Tracing session: 1f6b4440-050f-11e5-ba41-672ef88f159d
> ....
> <Details about the query>
> ....

      

+2


source







All Articles