喜欢集群"Connection Refused" 混乱

Akka Cluster "Connection Refused" Confusion

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

[WARN] [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] Association with remote system [akka.tcp://ClusterSystem@192.168.0.99:2552] has failed, address is now gated for [5000] ms. Reason: [Association failed with [akka.tcp://ClusterSystem@192.168.0.99:2552]] Caused by: [Connection refused: no further information: /192.168.0.99:2552]

我认为我遇到了连接被拒绝的错误,因为端口 2552 上没有任何监听,但我对原因感到困惑。 Akka 程序是如何放到节点上并开始的运行?为什么它适用于 127.0.0.1 而不是我的静态 IP?

据我所知,本教程或文档中没有明确说明:"You need to compile a separate program for your nodes."程序是从主 Akka 服务器推送到节点还是我需要创建另一个我的节点项目?

我猜是前者,但是 how/why 人们是否在与服务器相同的项目中进行节点开发?它们如何 运行 与服务器和节点相同的 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

application.conf 在 Raspberry Pi 节点 2 上(在节点 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

有了这个,我在尝试启动节点时得到了 "No route to host"。

编辑 2:

因为 main 在 simple.sample.cluster.simple.SimpleClusterApp 我必须用 "java -cp cluster.jar simple.sample.cluster.simple.SimpleClusterApp" 启动我的节点。这看起来对吗?我假设这是同一个教程项目,我对节点和桌面都是 compiling/assembling?或者我是否需要为我的节点创建一个完全不同的项目?我很困惑。该教程对新手来说太糟糕了。

嗨嗨

Akka 教程的这一部分假定您知道如何启动第 2 个节点。

为此,您需要使用 .conf 启动第二个 actorSystem,其中

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

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