What node does Cassandra store data on?

后端 未结 2 1976
北荒
北荒 2021-01-19 07:15

Is there a command or any way at all to know what data is stored on what nodes of Cassandra?

Im pretty new to Cassandra and haven\'t had much luck googling this ques

2条回答
  •  执笔经年
    2021-01-19 07:58

    Cassandra uses consistent hashing on the row's Partition key to determine where data is stored. Tokens are assigned to nodes and the consistent hash of the Partition key determines which node(s) will store the row.

    Partition key is the first part of the PRIMARY KEY in your table definition or in nested parentheses

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

    Some reading here on the ring and consistent hashing. You're probably using vNodes so I'd read a bit here too.

    At query time, you don't have to worry about which node has what. Your C* driver will select a coordinator node from the list provided that will find the rows based on your query.

    If you want to see details about what a query is doing in CQLSH, try turning tracing on:

    > TRACING ON;
    > SELECT * FROM table; 
    
    > Tracing session: 1f6b4440-050f-11e5-ba41-672ef88f159d
    > ....
    > 
    > ....

提交回复
热议问题