以官方示例akka-sample-cluster-java为例进行演示:
sbt 'runMain sample.cluster.factorial.FactorialFrontendMain'sbt 'runMain sample.cluster.factorial.FactorialBackendMain 2551'
sbt 'runMain sample.cluster.factorial.FactorialBackendMain 2551'现在一切都应该没问题了。
[info] [INFO] [05/11/2017 17:40:42.822] [ClusterSystem-akka.actor.default-dispatcher-3] [akka.cluster.Cluster(akka://ClusterSystem)] Cluster Node
[akka.tcp://ClusterSystem@127.0.0.1:2551] - Node
[akka.tcp://ClusterSystem@127.0.0.1:2552] is JOINING, roles [backend]
[info] [INFO] [05/11/2017 17:40:43.349] [ClusterSystem-akka.actor.default-dispatcher-4] [akka.cluster.Cluster(akka://ClusterSystem)] Cluster Node
[akka.tcp://ClusterSystem@127.0.0.1:2551] - Leader is moving node
[akka.tcp://ClusterSystem@127.0.0.1:2551] to [Up]
[info] [INFO] [05/11/2017 17:40:43.349] [ClusterSystem-akka.actor.default-dispatcher-4] [akka.cluster.Cluster(akka://ClusterSystem)] Cluster Node
[akka.tcp://ClusterSystem@127.0.0.1:2551] - Leader is moving node
[akka.tcp://ClusterSystem@127.0.0.1:2552] to [Up]
[info] [INFO] [05/11/2017 17:40:43.349] [ClusterSystem-akka.actor.default-dispatcher-4] [akka.cluster.Cluster(akka://ClusterSystem)] Cluster Node
[akka.tcp://ClusterSystem@127.0.0.1:2551] - Leader is moving node
[akka.tcp://ClusterSystem@127.0.0.1:56431] to [Up]但是,当我停止两个后端节点(通过ctrl + c)并重新启动它们时,任何一个后端节点的状态都是“正在加入”,并且不能更改为"up“。
[info] [INFO] [05/11/2017 17:39:32.356] [ClusterSystem-akka.actor.default-dispatcher-4] [akka.cluster.Cluster(akka://ClusterSystem)] Cluster Node [akka.tcp://ClusterSystem@127.0.0.1:2551] - Node [akka.tcp://ClusterSystem@127.0.0.1:2551] is JOINING, roles [backend]
[info] [INFO] [05/11/2017 17:39:35.637] [ClusterSystem-akka.actor.default-dispatcher-3] [akka.cluster.Cluster(akka://ClusterSystem)] Cluster Node
[akka.tcp://ClusterSystem@127.0.0.1:2551] - Node
[akka.tcp://ClusterSystem@127.0.0.1:56431] is JOINING, roles [frontend]前端节点如何在不重启前端节点的情况下自动加入种子节点?在重启前端节点时起作用。
发布于 2017-05-18 22:53:57
一旦集群形成,集群中的节点将停止寻找(其他)种子节点:种子节点仅用于集群的初始形成。
如果你想重新启动本例中的“后端”节点,并让它们加入已经在运行的“前端”节点,那么“后端”节点将必须启动到“前端”节点的连接,反之亦然。换句话说:“前端”节点然后充当这些新启动的后端节点的种子节点。
在此示例中,这有点棘手,因为“前端”节点不会侦听可预测的端口号。
如果您通过调整来实现这一点,请记住,此示例使用“自动关闭”作为关闭策略。这意味着当集群领导者在一段时间内不能到达某个节点时,它会将该节点标记为(永久)“关闭”。即使当节点返回时,它也不能再使用其原始地址加入集群,该地址现在被永久禁止进入集群(以防止某些未定义的行为和“分裂大脑”问题)。
请注意,在生产环境中,您可能不会使用自动关闭,而是运行一个工具,该工具可以“从外部”查看您的节点,并决定只考虑“无法访问”哪些节点,以及永久停止使用哪些节点。
https://stackoverflow.com/questions/43913512
复制相似问题