akka之种子节点

AKKA提供的cluser功能能够很便捷的创建一个分布式应用,在使用cluster时需要配置seed nodes节点,这里对seed nodes节点做一下介绍。

AKKA seed nodes 和普通节点没有什么本质区别,区别在于指定成为种子的节点在集群启动时应该首先被启动,因为其他节点需要种子节点的认证才能加入种子节点创建的集群。

但是一旦集群启动起来,seed nodes挂掉是没有影响的,只是如果新节点想加入集群如果还是指定的是挂掉的seed nodes是无法加入集群的,但是可以通过将seed nodes指定为集群中其他还活着的节点来加入集群

例如: 
集群启动时

seed-nodes = [
  "akka.tcp://ClusterSystem@127.0.0.1:2551",
  "akka.tcp://ClusterSystem@127.0.0.1:2552"
]
  • 1
  • 2
  • 3
  • 4

其它以非seed node节点身份启动的节点有:

"akka.tcp://ClusterSystem@127.0.0.1:2553"
"akka.tcp://ClusterSystem@127.0.0.1:2554"
  • 1
  • 2

此时,2551和2552都挂掉了,如果新节点akka.tcp://[email protected]:2555”想加入集群:

seed-nodes = [
  "akka.tcp://ClusterSystem@127.0.0.1:2551",
  "akka.tcp://ClusterSystem@127.0.0.1:2552"
]
  • 1
  • 2
  • 3
  • 4

这样是无法加入集群的,因为seed nodes都已经挂掉了,但是可以讲seed node节点指定为或者的节点,比如2553或者2554是可以加入集群的。

所以实际应用场景中,为了防止节点的下线,导致每次重启或者新加节点都要改动种子节点的配置,可以考虑将节点信息放在动态配置管理中,比如zookeeper。

猜你喜欢

转载自www.cnblogs.com/vana/p/9023831.html