这是一个场景:
- 我已经将scala项目与spray打包成jar文件。
- 在 Virtual Box 上的 RedHat 6.5 上启动 jar 文件(ip - 192.168.1.38)
- 在 Virtual Box 上的 RedHat 6.5 上启动 jar 文件(ip - 192.168.1.41)
- 一切都在本地运行 - 我可以向每个虚拟机发送 REST 请求并获得响应。
问题
Akka系统无法成为集群。我使用默认设置运行 192.168.1.38,但 192.168.1.41 有一个附加属性 - akka.cluster.seed-nodes,它设置为 akka.tcp://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="24495d775d5750414964151d160a15121c0a150a171c" rel="noreferrer noopener nofollow">[email protected]</a>:2551
。所以我得到:
[WARN] [12/09/2014 17:10:24.043] [mySystem-akka.remote.default-remote-dispatcher-8] [akka.tcp://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="24495d775d5750414964151d160a15121c0a150a1015" rel="noreferrer noopener nofollow">[email protected]</a>:2551/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FmySystem%40192.168.1.38%3A2551-0] Association with remote system [akka.tcp://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a5c8dcf6dcd6d1c0c8e5949c978b94939d8b948b969d" rel="noreferrer noopener nofollow">[email protected]</a>:2551] has failed, address is now gated for [5000] ms. Reason is: [Association failed with [akka.tcp://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fd9084ae848e899890bdccc4cfd3cccbc5d3ccd3cec5" rel="noreferrer noopener nofollow">[email protected]</a>:2551]].
没有其他错误或警告。另外我如何测试 akka 关联或打印调试 akka 关联设置?
Linux设置也会影响akka关联吗?
最佳答案
很可能 iptables
正在阻止特定端口,如果这是您的测试配置,只需禁用 iptables。
service iptables save
service iptables stop
chkconfig iptables off
service ip6tables save
service ip6tables stop
chkconfig ip6tables off
如果它无法帮助尝试使用命令 getenforce
检查您的 SELinux
配置,并且出于测试目的,您可以完全禁用它。 SELinux manual
如果是 application.conf
,请尝试对每个节点使用以下配置:
akka {
log-dead-letters = on
loglevel = "debug"
actor
{
provider = "akka.cluster.ClusterActorRefProvider"
}
extensions = ["akka.contrib.pattern.ClusterReceptionistExtension"]
remote {
log-remote-lifecycle-events = off
netty.tcp {
port = 6001
}
}
cluster {
seed-nodes = [
"akka.tcp://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="59183a2d362b0a202a2d3c341968606b77686f617768776a61" rel="noreferrer noopener nofollow">[email protected]</a>:6001",
"akka.tcp://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b0f1d3c4dfc2e3c9c3c4d5ddf08189829e8186889e819e8481" rel="noreferrer noopener nofollow">[email protected]</a>:6001"
]
auto-down-unreachable-after = 10s
}
}
与集群节点相关的所有日志都记录为 info
,但在测试环境中具有 debug
日志级别通常是个好主意。
当第二个节点加入集群时,您应该注意到以下日志:
INFO [ActorSystem-akka.actor.default-dispatcher-4] [Cluster(akka://ActorSystem)] - Cluster Node [akka.tcp://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="da9bb9aeb5a889a3a9aebfb79aebeaf4eaf4ebf4eeeb" rel="noreferrer noopener nofollow">[email protected]</a>:6001] - Marking node(s) as REACHABLE [Member(address = akka.tcp://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="054466716a77567c767160684534352b352b342b3134" rel="noreferrer noopener nofollow">[email protected]</a>:6001, status = Up)]
还可以使用 jmx akka.Cluster
MXBean 监控集群状态
{ "self-address": "akka.tcp://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6a2b091e05183913191e0f072a5b5a445a445b445258" rel="noreferrer noopener nofollow">[email protected]</a>:6001", "members": [ { "address": "akka.tcp://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d091b3a4bfa283a9a3a4b5bd90e1e0fee0fee1fee8e2" rel="noreferrer noopener nofollow">[email protected]</a>:6001", "status": "Up" } ], "unreachable": [ ] }
关于scala - 如何调试akka关联进程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27376606/