Akkalar没有看到对方

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

在Akka中,我向群集添加了两台不同的计算机。但是有一些问题。如果两台机器同时站起来,那么两侧就会成为领导者并且不会互相看见。或者因为类似的问题,他们没有看到对方。你知道他是否有解决方案吗?

java akka actor akka-cluster
1个回答
0
投票

取决于您如何配置群集,例如:1)在application.conf中的种子节点列表中进行硬编码:如果两台机器可以相互连接,则应该直接工作2)通过config,dns,tag(aws)发现机制)(由lightbend提供):基于配置的示例:

akka.management {
  contact-point-discovery {
    required-contact-point-nr = 2
    service-name = "MyApp"
    discovery-method = akka.discovery
  }
}

和一个条目

akka.discovery {
  method = config
    config {
      class = "akka.discovery.config.ConfigSimpleServiceDiscovery"

      # Location of the services
      services-path = "akka.discovery.config.services"
      # hosts
      services {
        MyApp { //name should match the name set in akka-management.conf for service-name (https://developer.lightbend.com/docs/akka-management/current/bootstrap/local-config.html)
          endpoints = [
            {
              host = "127.0.0.1"
            },
            {
              host = "127.0.0.2"
            }
        ]
      }
    }
  }
}

主机将是那些与您的机器匹配的主机。请注意,这需要构建文件中特定版本的“com.lightbend.akka.discovery”%%“akka-discovery-config”。通过发现,您还需要在每个节点的启动时调用AkkaManagement(actorSystem).start()和ClusterBootStrap(actorSystem).start()。

所以真的取决于你的配置。

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