1
0
mirror of https://github.com/chai2010/advanced-go-programming-book.git synced 2025-05-29 16:22:21 +00:00
2018-08-04 07:03:14 +08:00

10 lines
792 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 6.3 Raft协议
raft 是一种分布式一致性算法,其能够保证在 2n+1 的系统,有 n+1 以上的节点存活时,向集群中写入的数据保证不会丢失。相比 paxos其有更好的易读性和简洁性所以从诞生起便受到很多人的赞许。该算法与 paxos 类似,被广泛应用于分布式调度的元信息存储,或在存储领域进行日志复制。
开源界使用最为广泛的实现是基于 raft 实现的 etcd、consul不过 etcd 的 raft 和自身强绑定我们如果只是想使用算法的话并不是很方便。hashicorp 为我们直接开源了 raft 的算法库 `https://github.com/hashicorp/raft`,本节中,我们将基于该库实现几个小工具。
## 实现分布式状态机
## 实现分布式日志复制