Paxos协议/算法是分布式系统中比较重要的协议,它有多重要呢?
<分布式系统的事务处理>:
Google Chubby的作者Mike Burrows说过这个世界上只有一种一致性算法,那就是Paxos,其它的算法都是残次品。
<分布式存储系统>:
理解了这两个分布式协议之后(Paxos/2PC),学习其他分布式协议会变得相当容易。
学习Paxos算法有两部分:a) 算法的原理/证明;b) 算法的理解/运作。
理解这个算法的运作过程其实基本就可以用于工程实践。而且理解这个过程相对来说也容易得多。
网上我觉得讲Paxos讲的好的属于这篇:paxos图解及Paxos算法详解,我这里就结合进一步阐述。一些paxos基础通过这里提到的两篇文章,以及wiki上的内容基本可以理解。
Paxos在原作者的《Paxos Made Simple》中内容是比较精简的:
Phase 1
(a) A proposer selects a proposal number n and sends a prepare request with number n to a majority of acceptors.
(b) If an acceptor receives a prepare request with number n greater than that of any prepare request to which it has already responded, then it responds to the request with a promise not to accept any more proposals numbered less than n and with the highest-numbered pro-posal (if any) that it has accepted.
Phase 2
(a) If the proposer receives a response to its prepare requests (numbered n) from a majority of acceptors, then it sends an accept request to each of those acceptors for a proposal numbered n with a value v , where v is the value of the highest-numbered proposal among the responses, or is any value if the responses reported no proposals.
(b) If an acceptor receives an accept request for a proposal numbered n, it accepts the proposal unless it has already responded to a prepare request having a number greater than n.
借用paxos图解文中的流程图可概括为:

Paxos中有三类角色Proposer、Acceptor及Learner,主要交互过程在Proposer和Acceptor之间。
Proposer与Acceptor之间的交互主要有4类消息通信,如下图:
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-29828-1.html
Loveis4WallsMirrormirror#fx_4walls##fx全新回归#
这首最好听
是买不起