翻译内容:
NoSQL Distilled 第四章 Distribution Models
作者简介:
本节摘要:
今天主要说的内容是如何把分片和复制结合起来使用。
4.5. Combining Sharding and Replication 分片和复制双剑合璧
Replication and sharding are strategies that can be combined. If we use both master- slave replication and sharding (see Figure 4.4), this means that we have multiple masters, but each data item only has a single master. Depending on your configuration, you may choose a node to be a master for some data and slaves for others, or you may dedicate nodes for master or slave duties.
复制和分片可以联合起来使用。如果你使用主从复制和分片的方案,这意味着我们有多个master,但是每个数据块都只有一个master。按照你的配置,你可以选一个节点作为一些数据的master,也可以充当其他数据的slave,或者你可以安排一些节点做全职的主节点(master)或从节点(slave)。(译者曰:master和slave可以是兼职也可全职)
Figure 4.4. Using master-slave replication together with sharding
图4.4 把主从复制和分片一块使用
Using peer-to-peer replication and sharding is a common strategy for column- family databases. In a scenario like this you might have tens or hundreds of nodes in a cluster with data sharded over them. A good starting point for peer-to-peer replication is to have a replication factor of 3, so each
shard is present on three nodes. Should a node fail, then the shards on that node will be built on the other nodes (see Figure 4.5).
现在来说说对等复制和分片结合的方案。对等复制和分片合起来用的做法是列族数据库常用的做法。 在这种情况下,你的数据可能分布在成十上百个节点的集群上。一开始你可以用3作为复制因子,什么意思呢?就是把一个分片复制二份分别存到不同的节点上。(译者曰:hdfs默认就是三份)这样的话,如果一个节点出现故障了,那么这个节点上保存的那些分片数据则会由其他节点进行恢复重建(如图 4.5所示)。
Figure 4.5. Using peer-to-peer replication together with sharding
图 4.5 把对等复制和分片一块使用