View Cassandra Partitions using CQLSH -
using cassandra, how see how many partitions created base on how created primary key? have been following tutorial , mentions go bin/cassandra-cli
, use list
command. however, latest cassandra install not come , have read other articles online have indicated cli deprecated.
is there anyway me see partitions created using cqlsh?
thanks in advance!
first of have investigate cassandra.yaml
file see number of tokens configured. tells how many partitions each node own:
$ grep num_tokens conf/cassandra.yaml ... num_tokens: 128 ... $ grep initial_token conf/cassandra.yaml ... # initial_token: 1 ...
if initial token commented out, means node figure out it's own partition ranges during start-up.
next can check partition ranges using nodetool ring
command:
$ bin/nodetool ring datacenter: dc1 ========== address rack status state load owns token 9167006318991683417 127.0.0.2 r1 down normal ? ? -9178420363247798328 127.0.0.2 r1 down normal ? ? -9127364991967065057 127.0.0.3 r1 down normal ? ? -9063041387589326037
this shows partition range belongs node in cluster.
in example above each node owns 128 partition ranges. range between -9178420363247798327 , -9127364991967065057 belongs node 127.0.0.2.
you can use simple select tell each row's partition key:
cqlsh:mykeyspace> select token(key), key, added_date, title mytable; system.token(key) | key | added_date | title ----------------------+-----------+--------------------------+---------------------- -1651127669401031945 | first | 2013-10-16 00:00:00+0000 | hello world -1651127669401031945 | first | 2013-04-16 00:00:00+0000 | bye world 356242581507269238 | second | 2014-01-29 00:00:00+0000 | lorem ipsum 356242581507269238 | second | 2013-03-17 00:00:00+0000 | today tomorrow 356242581507269238 | second | 2012-04-03 00:00:00+0000 | it's meet (5 rows)
finding partition key in partition ranges tell record stored.
also can use nodetool
same in 1 simple step:
$ bin/nodetool getendpoints mykeyspace mytable 'first' 127.0.0.1 127.0.0.2
this tells records partition key 'first' located.
note: if of nodes down, getendpoints
command won't list nodes, though should store record based on replication settings.
Comments
Post a Comment