votequorum如何判定存活节点
oracle 19c集群在发生脑裂时,通过votequorum机制判定存活节点。核心逻辑是统计有效投票数,若超过总票数的一半(即 majority = total_votes / 2 + 1),则剩余节点组成合法集群继续运行;否则该部分节点将被驱逐(evicted)以保护数据一致性。

cssd心跳与网络分区处理
判定过程依赖于Cluster Synchronization Services (CSS)的心跳检测。当网络分区发生时,各子集独立计算本地存活节点数。如果某子集的节点数不足法定多数派,其上的cssd进程会主动触发本地节点的卸载流程,防止“双主”现象。

import time
import random
class VoteQuorumSimulator:
def __init__(self, total_nodes):
self.total_nodes = total_nodes
self.active_nodes = set(range(total_nodes))
self.quorum_threshold = (total_nodes // 2) + 1
def simulate_network_split(self, split_indices):
"""
模拟网络分区:将指定索引的节点从当前活跃集合中移除
:param split_indices: 被隔离的节点ID列表
"""
isolated = set(split_indices)
remaining = self.active_nodes - isolated
print(f"--- 网络分区发生 ---")
print(f"原节点总数: {self.total_nodes}")
print(f"被隔离节点: {isolated}")
print(f"剩余节点: {remaining}")
# 判定逻辑
if len(remaining) >= self.quorum_threshold:
status = "STAY (合法集群)"
action = "继续提供服务"
else:
status = "EVICTION (失去多数派)"
action = "卸载资源,停止服务"
print(f"法定多数派阈值: {self.quorum_threshold}")
print(f"判定结果: {status}")
print(f"执行动作: {action}")
return status
# 示例:5节点集群,发生脑裂,3个节点失联
sim = VoteQuorumSimulator(5)
sim.simulate_network_split([0, 1, 2])
print("\n--- 另一侧:2个节点存活 ---")
sim.simulate_network_split([3, 4])基于diskbeat仲裁盘的判定细节
在纯软件投票可能因网络延迟误判的情况下,Oracle RAC通常配置diskbeat(磁盘心跳)作为仲裁依据。当网络心跳中断时,节点会尝试写入仲裁盘。能成功写入仲裁盘的节点被视为“拥有仲裁权”,从而在网络分区中占据判定优势,确保只有一个子集能维持集群状态。


















