如何在多个服务器之间可靠地分片数据

问题描述 投票:0回答:1

我目前正在阅读一些分布式系统设计模式。当您必须处理大量数据(数十亿个整体或多个peta字节)时,设计模式之一就是将其分布在多个服务器或存储单元上。

解决方案之一是使用一致性哈希。这应该导致哈希中的所有服务器均匀分布。

这个概念很简单:我们只需添加新服务器,仅该范围内的服务器将受到影响,如果您松开服务器,则一致哈希中的其余服务器将被接管。这是散列中的所有服务器都具有相同数据(在内存,磁盘或数据库中)的时间。

我的问题是,我们如何处理从一致的哈希中添加和删除服务器的情况,因为哈希数据太多,因此无法将其存储在单个主机上。他们如何确定要存储哪些数据,什么不可以呢?

示例:

enter image description here

假设我们有2台机器正在运行,分别是“ 0”和“ 1”。它们开始达到最大容量的60%,因此我们决定增加一台机器“ 2”。现在,很大一部分机器0上的数据必须迁移到机器2上。我们将如何实现自动化,从而在不停机的情况下实现可靠​​运行。

[我自己建议的方法将是服务保持一致的哈希,并且机器将知道如何在彼此之间传输数据。添加新计算机时,一致性哈希服务将计算受影响的哈希范围。然后通知受影响的机器受影响的哈希范围,并且它们需要将受影响的数据传输到计算机2。一旦受影响的计算机完成了其数据的传输,它们将ACK返回到一致的哈希服务。一旦完成所有受影响的服务的数据传输,一致的哈希服务将开始向计算机2发送数据,并通知受影响的计算机它们现在可以删除其传输的数据。如果每个服务器上都有peta字节,则此过程可能需要很长时间。我们需要跟踪传输过程中更改的全部内容,以便确保以后进行同步,或者可以在传输过程中将写入/更新同时提交给计算机0和2。

我的方法行得通,但是我觉得来回冒险有点冒险,所以我想听听是否有更好的方法。

hash distributed-computing scalability consistent-hashing
1个回答
0
投票

我们将如何实现自动化,从而在不停机的情况下实现可靠​​运行?

这取决于用于存储数据的技术,但是例如,在Cassandra中,没有“中央”实体来控制流程,它几乎像其他所有事物一样完成;通过让节点彼此闲聊。当新节点加入群集时,没有停机时间(尽管性能可能会受到轻微影响)。

过程如下:

The new node joining the cluster is defined as an empty node without system tables or data.

When a new node joins the cluster using the auto bootstrap feature, it will perform the following operations

- Contact the seed nodes to learn about gossip state.
- Transition to Up and Joining state (to indicate it is joining the cluster; represented by UJ in the nodetool status).
- Contact the seed nodes to ensure schema agreement.
- Calculate the tokens that it will become responsible for.
- Stream replica data associated with the tokens it is responsible for from the former owners.
- Transition to Up and Normal state once streaming is complete (to indicate it is now part of the cluster; represented by UN in the nodetool status).

取自https://thelastpickle.com/blog/2017/05/23/auto-bootstrapping-part1.html

因此,当加入节点处于加入状态时,它正在从其他节点接收数据,但直到该过程完成时才准备好读取(Up状态)。

DataStax对此https://academy.datastax.com/units/2017-ring-dse-foundations-apache-cassandra?path=developer&resource=ds201-datastax-enterprise-6-foundations-of-apache-cassandra也有一些内容

© www.soinside.com 2019 - 2024. All rights reserved.