cassandra如何复制数据 [英] How cassandra replicates data

查看:139
本文介绍了cassandra如何复制数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想了解Cassandra中的复制机制。我阅读了关于数据分发的Datastax链接:

I am just curious to understand the mechanism of replication in Cassandra. I read the Datastax link about data distribution:

http://www.datastax.com/docs/1.2/cluster_architecture/data_distribution

在一致性哈希部分,它告诉Cassandra创建哈希值,并且基于该值将数据发送到容纳所生成的散列值的节点。之后,它显示数据在集群中的分布。现在我的问题是如何根据哈希值将这些数据复制到集群中的其他节点。

In the consistent hashing section it tells that Cassandra creates hash value for each primary key and based on that send the data to node that accommodates the generated hash value. After that it shows distribution of data in a cluster. Now my question is how it copies this data to other nodes in a cluster based on hash value.

这可能是一个非常基本的问题。如果可能,请通过示例解释。

This may be very basic question. Please explain by example if possible.

推荐答案

复制副本的发现方式取决于复制策略。对于没有虚拟节点的复制因子N的SimpleStrategy,Cassandra执行以下操作:

The way replicas are found depends on replication strategy. For the SimpleStrategy with replication factor N without virtual nodes Cassandra does the following:


  1. 哈希键


  2. 在该节点上存储密钥,并按令牌顺序存储接下来的N-1个节点

例如,假设你的节点有令牌0,10,20,30,你的复制因子是2.如果你的密钥有散列14,将被存储在具有标记20和30的节点上。如果您的密钥具有散列28,那么它将被存储在具有标记30和0的节点上。

As an example, suppose your nodes have tokens 0, 10, 20, 30 and your replication factor is 2. If your key has hash 14 then it will be stored on the nodes with tokens 20 and 30. If your key has hash 28 then it will be stored on the nodes with tokens 30 and 0.

虚拟节点,使用相同的想法,但如果物理节点已经接收到密钥,则虚拟节点将作为副本被跳过。

If you use virtual nodes, the same idea is used but virtual nodes will be skipped as replicas if the physical node has already received the key.

如果使用NetworkTopologyStrategy,达到该数据中心的配额。

If using NetworkTopologyStrategy, nodes are skipped if the quota for that data center is reached.

这篇关于cassandra如何复制数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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