当前位置: 首页 > 工具软件 > FastCFS > 使用案例 >

FastCFS数据一致性配置和实践

冯宪
2023-12-01

    FastCFS今天发布了v3.5,支持多数派数据复制,在网络不稳定或者系统繁忙等情况下,仍可保证数据一致性和可靠性。FastCFS v3.5从机制上保证了数据一致性,在实际使用中我们该如何进行软硬件配置呢?

    三副本既可以防leader脑裂,还可以采用多数派数据复制算法,保证数据一致性。对于访问量较大的企业,可以直接使用三副本。对于3副本或5副本等奇数副本数,FastCFS默认配置就是选举过半数和数据复制过半数,因此三副本情况下无需修改配置文件。fstore的cluster.conf配置片段如下:

[leader-election]
# the quorum for leader 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

[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
##  auto: set to majority when the number of nodes is odd,
##        otherwise set to any
# default value is auto
quorum = auto

    对于访问量不大的企业,出于性价比考虑,通常会使用两副本。FastCFS v3.4实现了公共选举节点,两副本引入公共选举节点也可实现选举过半防脑裂。fstore的cluster.conf中公共选举节点相关配置示例如下:

[leader-election]
# 其他配置项

# if enable vote node when the number of servers is even
# the default value is false
vote_node_enabled = true

# 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

    如果存在网络不稳定或者系统负载高等异常情况,不采用数据复制过半数机制就无法完全保证数据一致性。针对两副本,v3.5.1支持写入数据过半数自适应模式:如果两个节点都可用,则采用过半数确认机制,否则写入一个节点即可。友情提示:默认配置即支持本模式。

    另外,服务停机后重启事关数据一致性,需要给大家说明一下。以三副本为例,如果服务先后停机一段时间后重启,需要先启动停机时间最短的服务,最后启动停机时间最长的服务,为了避免数据不一致的情况发生,启动顺序千万不能搞反了;或者同时启动三个节点上的服务也是可以的。注:fdir和fstore服务通过restart正常重启是没有问题的。

    FastCFS v3.5.1是保证数据一致性和可靠性的一个里程碑版本,欢迎大家测试和使用。

 类似资料: