在 Akka.Cluster 中,Lighthouse/Seed 节点是用 Split Brain Resolver 解决脑裂问题的。
因此,在 Lighthouse/Seed 配置中,应该包含 Split Brain Resolver 的配置信息。
例如,以下是一个基本的 Lighthouse 配置示例:
akka {
actor.provider = cluster
remote.dot-netty.tcp {
transport-class = "Akka.Remote.Transport.DotNetty.TcpTransport, Akka.Remote"
applied-adapters = []
transport-protocol = tcp
port = 8090 # port can be any valid available port
hostname = "localhost" # hostname can be IP or DNS, but DNS is recommended
}
cluster {
seed-nodes = ["akka.tcp://MyCluster@localhost:4053"]
# add split-brain-resolver configuration here
}
}
在上例中,我们需要添加 Split Brain Resolver 配置。以下是一些示例配置:
split-brain-resolver {
# Mix majority strategy means that in a partition *where the number of nodes is odd*, the majority group should be merged.
# In a partition *where the number of nodes is even*, these nodes don't form a majority and should shut down.
# This can eventually cause the whole cluster to shut down, which is why this strategy is not recommended.
#mix-majority-strategy {
# thresholds {
# acceptable-size-difference = 1
# }
#}
keep-majority-strategy {
thresholds {
majority-size = 4
unreachable-size = 2
# if a node sees unreachable nodes with unreachability-level >=2, when it itself is a part of the majority, it will trigger downing those nodes
down-all-when-unstable = true
# if there are not enough reachable nodes to satisfy the threshold, the actor system will shut down
reachable-size = 3
}
}
}
对于以上示例中的 Lighthouse 配置,我们应该在 cluster
部分添加 Split Brain Resolver 的