【问题标题】:Akka Cluster "Connection Refused" ConfusionAkka 集群“拒绝连接”混乱
【发布时间】:2016-09-28 13:18:03
【问题描述】:

我一直在通过 akka-sample-cluster-app 教程和 documentation 学习 Akka 集群。我让它在本地运行(127.0.0.1),但我似乎无法使用我的静态 IP(192.168.0.99)让它工作。我这样做是为了快速进行健全性检查,因为我在尝试将 Raspberry Pi 用作节点时收到了类似的消息。

[警告] [05/30/2016 11:01:41.432] [ClusterSystem-akka.remote.default-remote-dispatcher-8] [akka.tcp://ClusterSystem@127.0.0.1:63599/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FClusterSystem%40192.168.0.99%3A2552-1] 与远程系统关联 [akka.tcp://ClusterSystem@192.168.0.99:2552] 失败,地址为 现在选通 [5000] 毫秒。原因:[关联失败 [akka.tcp://ClusterSystem@192.168.0.99:2552]] 原因:[连接 拒绝:没有更多信息:/192.168.0.99:2552]

我相信我收到了连接被拒绝的错误,因为端口 2552 上没有任何东西在监听,但我不知道为什么。 Akka 程序是如何被放到节点上并开始运行的?为什么它适用于 127.0.0.1 而不是我的静态 IP?

据我所知,本教程或文档中没有明确说明:“您需要为您的节点编译一个单独的程序。”那么程序是从主 Akka 服务器推送到节点还是我需要为我的节点创建另一个项目?

我猜是前者,但是人们如何/为什么在与服务器相同的项目中进行节点开发?它们作为服务器和节点运行同一个 jar 的方式有何不同?

编辑:

Address of Raspberry Pi Node 1: 192.168.0.8
Address of Raspberry Pi Node 2: 192.168.0.9
Address of Desktop Computer: 192.168.0.99

台式机上的application.conf(注意主机名)

#//#snippet
akka {

    log-dead-letters = off
    log-level = "debug"

  actor {
    provider = "akka.cluster.ClusterActorRefProvider"
  }
  remote {
    log-remote-lifecycle-events = off
    netty.tcp {
      hostname = "192.168.0.99"
      port = 2552
    }
  }

  cluster {
    seed-nodes = [
      "akka.tcp://ClusterSystem@192.168.0.8:2552",
      "akka.tcp://ClusterSystem@192.168.0.9:2552"]

    #//#snippet
    # excluded from snippet
    auto-down-unreachable-after = 10s
    #//#snippet
    # auto downing is NOT safe for production deployments.
    # you may want to use it during development, read more about it in the docs.
    #
    # auto-down-unreachable-after = 10s
  }
}

# Disable legacy metrics in akka-cluster.
akka.cluster.metrics.enabled=off

# Enable metrics extension in akka-cluster-metrics.
akka.extensions=["akka.cluster.metrics.ClusterMetricsExtension"]

# Sigar native library extract location during tests.
# Note: use per-jvm-instance folder when running multiple jvm on one host.
akka.cluster.metrics.native-library-extract-folder=${user.dir}/target/native
#//#snippet

在 Raspberry Pi 节点 2 上的 application.conf(在节点 1 上类似,只是主机名不同)

#//#snippet
akka {

    log-dead-letters = off
    log-level = "debug"

  actor {
    provider = "akka.cluster.ClusterActorRefProvider"
  }
  remote {
    log-remote-lifecycle-events = off
    netty.tcp {
      hostname = "192.168.0.9"
      port = 2552
    }
  }

  cluster {
    seed-nodes = [
      "akka.tcp://ClusterSystem@192.168.0.8:2552",
      "akka.tcp://ClusterSystem@192.168.0.9:2552"]

    #//#snippet
    # excluded from snippet
    auto-down-unreachable-after = 10s
    #//#snippet
    # auto downing is NOT safe for production deployments.
    # you may want to use it during development, read more about it in the docs.
    #
    # auto-down-unreachable-after = 10s
  }
}

# Disable legacy metrics in akka-cluster.
akka.cluster.metrics.enabled=off

# Enable metrics extension in akka-cluster-metrics.
akka.extensions=["akka.cluster.metrics.ClusterMetricsExtension"]

# Sigar native library extract location during tests.
# Note: use per-jvm-instance folder when running multiple jvm on one host.
akka.cluster.metrics.native-library-extract-folder=${user.dir}/target/native
#//#snippet

当我尝试启动它时,我在节点上得到“没有路由到主机”。

编辑 2:

因为 main 位于 simple.sample.cluster.simple.SimpleClusterApp 我必须使用“java -cp cluster.jar simple.sample.cluster.simple.SimpleClusterApp”启动我的节点。这看起来对吗?我假设这是我正在为节点和桌面编译/组装的同一个教程项目?还是我需要为我的节点创建一个完全不同的项目?我很混乱。该教程对新手来说很糟糕。

【问题讨论】:

    标签: scala sbt akka typesafe-activator akka-cluster


    【解决方案1】:

    嗨嗨。

    在 Akka 教程的这一部分中,假设您知道如何启动 2-nd 节点。

    为此,您需要使用 .conf 启动 2-nd actorSystem,其中

     netty.tcp {
          hostname = "192.168.0.99"
          port = 2552
        }
    

    并在您的第一个节点的种子写入地址中。

    【讨论】:

    • 您好,感谢您的帮助。请参阅我对我的 conf 文件的编辑。我绝对不知道如何启动我的第二个节点!我尝试使用其 IP 作为主机名为我的节点生成一个 jar(使用 sbt 程序集),但是当我尝试启动它时得到“没有到主机的路由”。我编译了我的桌面版本,主机名为 192.168.0.99。
    • 您的拳头配置错误。 netty.tcp { hostname = "192.168.0.99" port = 2552 } 主机名必须是 192.168.0.8
    • 哦。我得到了它。在每个种子节点中写入所有 3 个节点。
    • 来自 0.9 的节点不知道来自 0.99 的节点并且不会从她那里获取连接。
    • 我不太清楚你的意思。你能修改你的答案吗?将所有三个节点写入哪个conf?种子 conf 或桌面 conf,或两者兼而有之?如果我不想让我的桌面成为一个节点,而只是管理它们怎么办?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-05
    • 2020-07-14
    相关资源
    最近更新 更多