节点可扩缩的Percona集群,能否用加权仲裁避免脑裂?
Great question—weighted arbitration in Percona XtraDB Cluster (PXC) is absolutely a valid way to mitigate split-brain scenarios, and your idea of using asymmetric weights to break symmetry is spot-on. Let’s break this down clearly:
Why Your 127+n Weighting Strategy Works
Your plan to assign unique weights like 127, 128, 129, etc., targets the root cause of split-brain in symmetric clusters: tied vote counts during network partitions. In standard quorum systems, a split into two equal-sized groups leaves neither side able to reach quorum, leading to conflicting active partitions. By making each node’s weight unique, you eliminate the possibility of equal vote sums across any possible partition—guaranteeing only one subset can hit the quorum threshold.
How This Plays Out for Your Cluster Sizes
Let’s map this to your 1, 2, and 3-node deployment scenarios:
- 1-node cluster: No split-brain risk by default, but assigning a weight like
127doesn’t cause any issues. - 2-node cluster: Use weights
127and128. Total weight sums to255, so quorum requires(255/2)+1 = 128votes. If the network splits, only the node with weight128can reach quorum—it stays online, while the other node shuts down automatically. No split-brain. - 3-node cluster: Weights
127,128,129sum to384, requiring193votes for quorum. Any partition scenario:- A single node can’t reach 193 votes, so it shuts down.
- Any pair of nodes will have at least
127+128=255votes, which meets quorum—this subset stays active. - There’s no way for two separate partitions to both hit quorum, since all weights are unique and sequential, so no two subset sums can be equal.
Why You Might Not Find Explicit Documentation for This Exact Pattern
PXC’s official docs mention weighted quorum as a tool for asymmetric clusters (like multi-data-center setups), but they don’t spell out this specific 127+n trick because it’s a logical extension of the core principle: avoid equal vote totals across possible partitions. Any weight distribution that achieves this works, and your sequential approach is just a clean, reliable implementation of that idea.
Quick Configuration Tips
- Set weights in your node’s
my.cnf(ormy.ini) using thewsrep_provider_optionsparameter:wsrep_provider_options="pc.weight=127" # For first node wsrep_provider_options="pc.weight=128" # For second node - Remember that PXC calculates quorum as
(total_weight / 2) + 1by default for weighted setups—double-check this matches your expected threshold when scaling. - When dynamically adding nodes, assign each a new unique weight (e.g.,
130for a 4th node) to maintain the asymmetric sum.
Caveats to Keep In Mind
- Weighted arbitration reduces split-brain risk but doesn’t eliminate all edge cases (e.g., node weight misconfiguration or rare quorum calculation bugs). Pair this with other mitigations like
evs.auto_evict(to auto-evict unresponsive nodes) and regular cluster health checks. - For 2-node clusters, you might also want to enable
pc.ignore_sbas an extra safety net, though your weighted setup should already prevent splits.
内容的提问来源于stack exchange,提问作者demented hedgehog

