简体   繁体   English

确定Cassandra中的写入节点

[英]Determining write nodes in Cassandra

I've just started reading about Cassandra and I can't quite understand how Cassandra manages to decide which nodes should it write the data to. 我刚刚开始阅读有关Cassandra的文章,但我不太了解Cassandra如何决定将数据写入哪个节点。

What I understand, is that Cassandra uses a part of primary key, specifically partition key, and partitioner to get a token by hashing the partition key, therefore a node/vnode to which that token is bound to. 我所了解的是,Cassandra使用主键的一部分(特别是分区键)和分区器通过散列分区键来获取令牌,因此该令牌绑定到的节点/ vnode。 Now let's say I have 2 nodes in my cluster, each has 256 vnodes on it + I'm not using any clustering keys, just a simple PK and a bunch of simple columns. 现在让我们说我的集群中有2个节点,每个节点上都有256个vnode +我没有使用任何集群键,只是一个简单的PK和一堆简单的列。 Hashing partition key would clearly determine where the data should go. 散列分区键将明确确定数据应存放在何处。 By this logic, there would be only 512 unique records available for storage. 按照这种逻辑,将只有512个唯一记录可用于存储。 Would be funny if true. 如果为真,那会很有趣。 So am I wrong at the partitioner part? 那么我在分区器部分错了吗?

Consider the base case: just a single node, with a single token. 考虑一个基本情况:只有一个节点,带有一个令牌。 Do you think it can story only one record ? 您认为它只能讲一张唱片吗? Of course not. 当然不是。

The hash determines which node the row will go to, true. 哈希确定该行将转到哪个节点,为true。 But the primary key determines where in the node the row will be stored. 但是主键决定了该行将在节点中存储的位置。 And many distinct primary keys may result in the same hash, but they will all be stored separately by the node. 并且许多不同的主键可能会导致相同的哈希,但是它们将全部由节点分别存储。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM