简体   繁体   English

自动选择节点集群中的领导者

[英]Automatic selection of a leader in a cluster of nodes

What are the best methods/algorithms available to select a leading node in a cluster of nodes, knowing that nodes come up and down at anytime? select 是节点集群中的领先节点,知道节点随时会上下波动,有哪些最佳方法/算法可用? If implementations are available in Java, it is a plus.如果实现在 Java 中可用,这是一个加号。

I've implemented the Paxos algorith before in Java.我之前在 Java 中实现了 Paxos 算法。 It's very useful, and fairly simple.它非常有用,而且相当简单。 (It took about 16 hours to put together a demo of it, using Threads to simulate servers. I was also much worse at threading then!) (花了大约 16 个小时来制作它的演示,使用 Threads 来模拟服务器。当时我在线程方面也差很多!)

It won't help you select the leader exactly... but what it will do is allow the various nodes to agree on a leader.它不会帮助你 select 正是领导者......但它会做的是让各个节点就领导者达成一致。 So you have this leader selection algorithm, but because each node is going to pick it's own node to lead, you may find a "civil war" among your nodes.所以你有这个领导者选择算法,但是因为每个节点都会选择它自己的节点来领导,你可能会在你的节点之间发现一场“内战”。 The Paxos algorithm allows you to say which picked leader is the real leader. Paxos 算法允许您说出哪个领导者是真正的领导者。

http://en.wikipedia.org/wiki/Paxos_%28computer_science%29 http://en.wikipedia.org/wiki/Paxos_%28computer_science%29

You can look through the sources of JGroups .您可以查看JGroups的来源。 (keyword: "coordinator", check out chapter 7 in jGroups manual) (关键字:“协调员”,查看 jGroups 手册中的第 7 章

Some options:一些选项:

I have personally implemented it with Hazelcast and JGroups and say that both were fairly straight-forward and simple.我亲自用 Hazelcast 和 JGroups 实现了它,并说两者都相当简单明了。 For a new project, I'd go with Hazelcast.对于一个新项目,我将 go 与 Hazelcast。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM