将数据存储在哪个节点上

将数据存储在哪个节点上

本文介绍了Cassandra 将数据存储在哪个节点上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么命令或方法可以知道Cassandra的哪些节点上存储了哪些数据?

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

我对 Cassandra 很陌生,在谷歌上搜索这个问题时运气不佳.

Im pretty new to Cassandra and haven't had much luck googling this question.

谢谢!

推荐答案

您可以使用 nodetool getendpoints.

$ nodetool getendpoints mykeyspace tbl '8546200'
192.168.73.188
192.168.73.190

我不知道这是否是您要查找的内容.AFAIK 没有办法完全查询表或键空间中所有行的负责节点.但正如 Blake 指出的那样,您的应用程序并不真正需要担心这一点.

I don't know if that's what you're looking for or not. AFAIK there isn't a way to flat-out query the responsible nodes for all rows in a table or keyspace. But as Blake pointed out, your application doesn't really need to worry about that.

如果您真的想知道,您可以使用分区键上的 token 函数查询您的表.这是一个使用 Blake 模式的示例:

If you really wanted to find out, you could query your table using the token function on your partition key. Here's an example using Blake's schema:

SELECT token(partition_key),partition_key FROM tbl;

这将列出带有分区键的散列令牌.然后你可以运行一个 nodetool ring 来列出每个节点的令牌范围,并查看哪些节点负责该范围.请注意,如果您使用 vNodes,您的输出将非常大(默认情况下每个 256 行).

That would list the hashed tokens with your partition keys. Then you could run a nodetool ring to list out the token ranges for each node, and see which nodes are responsible for that range. Note that if you are using vNodes your output will be pretty big (256 lines for each, by default).

这篇关于Cassandra 将数据存储在哪个节点上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 09:04