【问题标题】:Akka does not see each other阿卡不相见
【发布时间】:2019-02-27 18:45:43
【问题描述】:

在 Akka 中,我将两台不同的机器添加到集群中。但也有一些问题。如果 2 台机器同时站起来,则 2 方作为领导者离开,互不相见。或者因为类似的问题,他们互不相见。不知道他有没有解决办法?

【问题讨论】:

    标签: java akka actor akka-cluster


    【解决方案1】:

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

    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()。

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

    【讨论】:

      猜你喜欢
      • 2014-03-15
      • 1970-01-01
      • 2018-07-09
      • 1970-01-01
      • 1970-01-01
      • 2014-02-13
      • 1970-01-01
      • 2014-11-15
      • 1970-01-01
      相关资源
      最近更新 更多