Data replication

Data replication

Cassandra stores replicas on multiple nodes to ensure reliability and fault tolerance. A replication strategy determines the nodes where replicas are placed. The total number of replicas across the cluster is referred to as the replication factor.

A replication factor of 1 means that there is only one copy of each row in the cluster. If the node containing the row goes down, the row cannot be retrieved. A replication factor of 2 means two copies of each row, where each copy is on a different node.

All replicas are equally important; there is no primary or master replica. As a general rule, the replication factor should not exceed the number of nodes in the cluster. However, you can increase the replication factor and then add the desired number of nodes later.

Two replication strategies are available: SimpleStrategy/NetworkTopologyStrategy
When deciding how many replicas to configure in each datacenter, the two primary considerations are:

(1) being able to satisfy reads locally, without incurring cross data-center latency

(2) failure scenarios.

SimpleStrategy

将第一个副本放置在由分区器确定的节点上。其他副本将顺时针放置在环中的下一个节点上,而不考虑拓扑(机架或数据中心位置)。

NetworkTopologyStrategy

通过顺时针走环,直到到达另一个机架中的第一个节点,将副本放置在同一数据中心。

由于同一机架上的节点(或类似的物理分组)经常同时由于电源、冷却或网络问题而失败,因此尝试将副本放置在不同的机架上。

posted @ 2021-03-21 21:35  YanyuWu  阅读(54)  评论(0编辑  收藏  举报