1
我用play app定義了一個akka集羣。Akka沒有自動加入種子節點
application.conf
akka {
actor {
provider = "akka.cluster.ClusterActorRefProvider"
}
remote {
log-remote-lifecycle-events = off
netty.tcp {
hostname = "192.168.1.100"
port = 2552
}
}
cluster {
seed-nodes = [
"akka.tcp://[email protected]:2552",
"akka.tcp://[email protected]:2552",
"akka.tcp://[email protected]:2552"]
auto-down-unreachable-after = 10s
}
}
然後我定義了集羣監聽
class ClusterListener extends Actor with ActorLogging {
def receive = {
case state: CurrentClusterState =>
log.info("Current members: {}", state.members.mkString(", "))
case MemberUp(member) =>
log.info("Member is Up: {}", member.address)
case UnreachableMember(member) =>
log.info("Member detected as unreachable: {}", member)
case MemberRemoved(member, previousStatus) =>
log.info("Member is Removed: {} after {}",
member.address, previousStatus)
case _: ClusterDomainEvent => // ignore
}
}
而且開始我的應用程序是這樣
val clusterListener = Akka.system.actorOf(Props[ClusterListener], "cluster-listener")
Cluster(Akka.system).subscribe(clusterListener, classOf[ClusterDomainEvent])
我首先開始在192.168.1.100的應用,它加入。
然後我開始在
192.16.1.101
和192.16.1.102
上的同一個應用程序。
但是第一個種子節點永遠不會收到連接事件!
我該怎麼做,讓其他節點加入這個羣集?