如何选择在群集中运行的节点之间的主节点? [英] How to elect a master node among the nodes running in a cluster?

查看:163
本文介绍了如何选择在群集中运行的节点之间的主节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写一个托管的云堆栈(在硬件级别的云服务提供商像EC2的顶部),以及一个问题,我将面临很快为:

I'm writing a managed cloud stack (on top of hardware-level cloud providers like EC2), and a problem I will face soon is:

如何几个相同的节点决定哪一个成为高手? (即认为在EC2上运行5个服务器,其中一人有可能成为一个高手了,其他的都成为奴隶。)

How do several identical nodes decide which one of them becomes a master? (I.e. think of 5 servers running on EC2. One of them has to become a master, and other ones have to become slaves.)

我看了使用MongoDB的算法的描述,似乎pretty的复杂,也取决于选票的概念 - 即两个节点独自将无法决定任何事情。此外他们的做法有显著延迟它产生的结果之前。

I read a description of the algorithm used by MongoDB, and it seems pretty complicated, and also depends on a concept of votes — i.e. two nodes left alone won't be able to decide anything. Also their approach has a significant delay before it produces the results.

  1. 我不知道是否有任何那么复杂,KISS-embrasing办法是什么?他们是广泛使用的,或者是他们冒险采用?

  1. I wonder if there are any less complicated, KISS-embrasing approaches? Are they used widely, or are they risky to adopt?

假设我们已经拥有了服务器的列表。然后,我们可以只选出一个是和有一个数值最小的IP地址。什么是这种方法的缺点?

Suppose we already have a list of servers. Then we can just elect the one that is up and has a numerically smallest IP address. What are downsides of this approach?

为什么MongoDB的算法如此复杂?

Why is MongoDB's algorithm so complicated?

这是如何选出新的主群集?,这给了较少的细节,并没有被回答了6个月,所以我觉得这是适当的,开始一个新的问题。

This is a duplicate of How to elect new Master in Cluster?, which gives less details and has not been answered for 6 months, so I feel it is appropriate to start a new question.

(堆栈我工作的是开源的,但它在发展,不给的链接在这里的一个非常早期的阶段。)

(The stack I'm working on is open-source, but it's on a very early stage of development so not giving a link here.)

更新:根据答案,我设计了一个简单的一致算法,你可以找到在GitHub上一个JavaScript(CoffeeScript的)实现: majority.js

UPDATE: based on the answers, I have designed a simple consensus algorithm, you can find a JavaScript (CoffeeScript) implementation on GitHub: majority.js.

推荐答案

领导人选举算法通常考虑分裂大脑作为故障案例来支持。如果你认为这不是失败的节点,但是在网络,你可能会碰到,所有节点都在的情况下,却不能彼此交谈。然后,你可能最终有两个主人。

Leader election algorithms typically consider the split brain as a fault case to support. If you assume that it's not the nodes that fail but the networking, you may run into the case where all nodes are up, but fail to talk to each other. Then, you may end up with two masters.

如果你可以从你的错模型(即,如果你只考虑节点故障)排除裂脑,你的算法(领导者是一个具有最小地址)的罚款。

If you can exclude "split brain" from your fault model (i.e. if you consider only node failures), your algorithm (leader is the one with the smallest address) is fine.

这篇关于如何选择在群集中运行的节点之间的主节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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