随笔 - 746  文章 - 0  评论 - 39  阅读 - 79万

FastCFS:再谈 选主 与 过半写

这二者乍一看好像是一回事:都是要求遵循大多数原则(即过半数原则)。

其实,在概念上是不同的!

 

选主:本质是功能角色的概念。“国不能一日无主、群龙不能无首;否则,则是”一盘散沙、溃不成军“。

  对于FastCFS组件的群集来说,必须要有master,这个master是在server中自动选出来的,选择master的过程需要遵循大多数原则。

  因此,对于一个只有偶数个servers的群集来说,必须要引入vote角色才能解决该问题。对于奇数个servers的群集则没有这个问题。

 

过半写:指的是数据落地安全层面的概念。

  对于FastCFS的servers之间的数据同步,必须满足超过过半数的节点落地,如此才能保证任何时候至少都有1份最新版本的数据落地。

  加上群集健康运行需要保持的servers数量的约束,可以保证任何时候群集都是数据安全的,保证具有可以在各种故障中恢复数据的能力。

  vote角色不承载正常的数据备份功能,vote对于过半写无意义,也不会计入

  

所以,这是2个不同的东西。FastCFS中可以根据实际情况去分别选择不同的策略。

进一步,我们应该要保证任何时候都要首先满足“过半写”,然后满足“选主”,这样才能保证一个健康的群集。

 

细心的话,你可能会意识到:

  对于2节点群集来说,非常脆弱:我们即使通过引入vote角色,如果仅有1个正常数据节点,虽然群集能正常“选主”,

但此时,无法满足“过半写”的基本条件,我们必须选择适当的写策略,否则很很容易发生数据安全层面的“脑裂”问题

  特殊的,1节点群集,是个特殊的奇数群集,满足“选主”,也不满足“过半写”,只能特殊场景使用。

 

========================================================================

复制代码
[master-election]
# the quorum for master election
# set quorum to majority to avoid brain-split
# value list:
##  any: no requirement
##  majority: more than half
##  auto: set to majority when the number of nodes is odd,
##        otherwise set to any
# default value is auto
quorum = auto
# 注意:选主是程序启动时就一次性确定了的! 要么任意选定any、要么大多数majority!
# 而自动auto的意义在于,程序启动时自己根据节点的奇偶数情况来自动确定any或majority(呵呵,而这一自动决策不一定是你想要的)
# if enable vote node when the number of servers is even # the default value is false vote_node_enabled
= false # the cluster config filename of the vote node # this parameter is valid when vote_node_enabled is true vote_node_cluster_filename = ../vote/cluster.conf [data-replication] # the quorum for data replication # set quorum to majority for strict data consistency and high data security # value list: ## any: no requirement ## majority: more than half strictly ## smart: set to majority when more than half nodes are active, ## otherwise set to any, smart mode is mainly for two replicas ## auto: set to majority when the number of nodes is odd, ## otherwise set to smart # default value is auto quorum = auto # 数据写方面,基本的也同样只有任意的any 或者大多数的majority
# auto也是根据节点奇偶数情况自动选择大多数majority或智能模式smart
# 特殊的智能smart:自动根据活动节点数自动适应来选择任意的any或大多数majority。
# 智能smart主要特点是根据活动节点数动态自适应
# 疑问:我们是不是应该总选择smart?!!!

# deactive the slave node when connect fail times exceeds this parameter # this parameter is valid when quorum is smart or # quorum is auto and the number of nodes is even # default value is
3 deactive_on_failures = 3
复制代码

 

posted on   jinzhenshui  阅读(110)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
历史上的今天:
2022-04-07 Windows Server:DHCP 服务:一点总结
2022-04-07 由学习windows server 的 DHCP 服务功能引申学习汇总的一张图
2010-04-07 Sqlserver:代理作业调度的时间不准确.作业停止问题

点击右上角即可分享
微信分享提示