Cassandra Vnodes和令牌范围 [英] Cassandra Vnodes and token Ranges

查看:97
本文介绍了Cassandra Vnodes和令牌范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道Vnodes通过在cassandra.yaml文件中设置num_tokens为每个节点形成许多令牌范围。

I know that Vnodes form many token ranges for each node by setting num_tokens in cassandra.yaml file.

例如(a),我有6个节点,我为每个节点设置了num_token = 256。在这6个节点中形成了多少个虚拟节点,即每个物理节点中包含多少个虚拟节点或子令牌范围。

say for example (a), i have 6 nodes, each node i have set num_token=256. How many virtual nodes are formed among these 6 nodes that is, how many virtual nodes or sub token ranges contained in each physical node.

根据我的理解,每一个节点已将num_token分配为256,则意味着所有6个节点每个都包含256个vnode。这句话是真的吗?如果不是,则vnode如何在每个节点中形成令牌范围(显然是随机的)。如果有人可以用(a)中提到的示例来解释我,那将真的很方便。

According to my understanding, when every node has assigned num_token as 256, then it means that all the 6 nodes contain 256 vnodes each. Is this statement true? if not then, how vnodes form the range of tokens (obviously random) in each node. It would be really convenient if someone can explain me with the example mentioned as (a).

Vnodes的环在此URL中表示什么:=> http://docs.datastax.com/en/cassandra/3。 x / cassandra / images / arc_vnodes_compare.png (摘自: http://www.datastax.com/dev/blog/virtual-nodes-in-cassandra-1-2

what is the Ring of Vnodes signify in this url:=> http://docs.datastax.com/en/cassandra/3.x/cassandra/images/arc_vnodes_compare.png (taken from: http://www.datastax.com/dev/blog/virtual-nodes-in-cassandra-1-2 )

推荐答案

使用MurMur3哈希函数将Cassandra中的每个分区键转换为数字令牌值。令牌范围在-2 ^ 63到+ 2 ^ 63 -1之间
num_token定义为节点分配多少令牌范围。这与签名的Java long相同。每个节点计算令牌范围内的256个(num_tokens)个随机值并通知其他节点它们是什么,因此,当一个节点需要协调对特定令牌的请求时,它会根据复制因子和DC知道是哪个节点负责/机架放置。
对该功能的更好描述是自动令牌范围分配,以提供更好的流功能,称其为虚拟有点令人困惑。
在您的情况下,您有6个节点,每个节点集具有256个令牌范围,因此您有6 * 256个令牌范围,每个心理节点都包含256个令牌范围。

Every partition key in Cassandra is converted to a numerical token value using the MurMur3 hash function. The token range is between -2^63 to +2^63 -1 num_token defines how many token ranges are assigned to a node. this is the same as the signed java long. Each node calculates 256 (num_tokens) random values in the token range and informs other nodes what they are, thus when a node needs to coordinate a request for a specific token it knows which nodes are responsible for it, according to the Replication Factor and DC/rack placement. A better description for this feature would be "automatic token range assignment for better streaming capabilities", calling it "virtual" is a bit confusing. In your case you have 6 nodes, each set with 256 token ranges so you have 6*256 token ranges and each psychical node contains 256 token ranges.

例如,考虑2个节点,其num_tokens设置为4,令牌范围为0到100。
节点1计算令牌17、35、77、92
节点2计算令牌4、25、68、85
环显示了令牌范围的分布,在这种情况下
节点2负责令牌范围4-17、25-35、68-77、85-92,其余节点负责1。

For example consider 2 nodes with num_tokens set to 4 and token range 0 to 100. Node 1 calculates tokens 17, 35, 77, 92 Node 2 calculates tokens 4, 25, 68, 85 The ring shows the distribution of token ranges in this case Node 2 is responsible for token ranges 4-17, 25-35, 68-77, 85-92 and node 1 for the rest.

这篇关于Cassandra Vnodes和令牌范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆