我通过 akka-sample-cluster-app 教程和documentation一直在研究Akka Clusters。我让它在本地运行(127.0.0.1),但我似乎无法使用我的静态IP(192.168.0.99)。我这样做是为了快速进行健全性检查,因为我在尝试使用我的Raspberry Pi作为节点时收到了类似的消息。
[WARN] [05/30/2016 11:01:41.432] [ClusterSystem-akka.remote.default-远程调度-8] [akka.tcp://ClusterSystem@127.0.0.1:63599 /系统/ endpointManager / reliableEndpointWriter-akka.tcp%3A%2F%2FClusterSystem%40192.168.0.99%3A2552-1] 与远程系统联系 [akka.tcp://ClusterSystem@192.168.0.99:2552]失败了,地址是 现在为[5000] ms门控。原因:[协会失败了 [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 Node 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
有了这个,我得到了#34;没有主持人的路线"当我试图提起它时,在节点上。
编辑2:
因为main位于simple.sample.cluster.simple.SimpleClusterApp我必须使用" java -cp cluster.jar simple.sample.cluster.simple.SimpleClusterApp"启动我的节点。那似乎对吗?我假设这是我为节点和桌面编译/组装的教程项目?或者我是否需要为我的节点创建一个完全不同的项目?我很困惑。这个教程对新手来说很糟糕。
答案 0 :(得分:1)
日冰。
在Akka教程的这一部分假设您知道如何启动第二个节点。
为此你需要用.conf启动第二个actorSystem,其中
netty.tcp {
hostname = "192.168.0.99"
port = 2552
}
和第1个节点的种子写地址。