<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Distributed - 标签 - 星河拾贝录</title><link>https://blog.liubang.cc/tags/distributed/</link><description>Distributed - 标签 - 星河拾贝录</description><generator>Hugo -- gohugo.io</generator><language>zh-CN</language><managingEditor>it.liubang@gmail.com (liubang)</managingEditor><webMaster>it.liubang@gmail.com (liubang)</webMaster><copyright>Copyright © 2019-2026 LiuBang. All Rights Reserved.</copyright><lastBuildDate>Mon, 25 May 2020 00:00:00 +0000</lastBuildDate><atom:link href="https://blog.liubang.cc/tags/distributed/" rel="self" type="application/rss+xml"/><item><title>分布式协议</title><link>https://blog.liubang.cc/posts/storage/2020-05-25-%E5%88%86%E5%B8%83%E5%BC%8F%E5%8D%8F%E8%AE%AE/</link><pubDate>Mon, 25 May 2020 00:00:00 +0000</pubDate><author><name>liubang</name></author><guid>https://blog.liubang.cc/posts/storage/2020-05-25-%E5%88%86%E5%B8%83%E5%BC%8F%E5%8D%8F%E8%AE%AE/</guid><description><![CDATA[<h2 id="拜占庭将军问题" class="headerLink">
    <a href="#%e6%8b%9c%e5%8d%a0%e5%ba%ad%e5%b0%86%e5%86%9b%e9%97%ae%e9%a2%98" class="header-mark"></a>拜占庭将军问题</h2><h3 id="简介" class="headerLink">
    <a href="#%e7%ae%80%e4%bb%8b" class="header-mark"></a>简介</h3><ul>
<li>在可能存在叛军的情况下，采用合适的通讯协议，让多个将军达成共识，执行统一的作战计划</li>
<li>二忠一叛难题</li>
<li>它是分布式领域最复杂的容错模型</li>
<li>莱斯利·兰伯特（Leslie Lamport）<a href="https://www.microsoft.com/en-us/research/uploads/prod/2016/12/The-Byzantine-Generals-Problem.pdf" target="_blank" rel="noopener noreferrer">The Byzantine Generals Problem</a></li>
</ul>
<h3 id="二忠一叛难题" class="headerLink">
    <a href="#%e4%ba%8c%e5%bf%a0%e4%b8%80%e5%8f%9b%e9%9a%be%e9%a2%98" class="header-mark"></a>二忠一叛难题</h3><p><figure><a class="lightgallery" href="/images/2020-05-25/bzt1.png#center" title="" data-thumbnail="/images/2020-05-25/bzt1.png#center" data-sub-html="<h2>拜占庭将军问题：三个将军的通信场景</h2>"><img  loading="lazy" src='/images/2020-05-25/bzt1.png#center'     ></a><figcaption class="image-caption">拜占庭将军问题：三个将军的通信场景</figcaption>
</figure></p>
<p><figure><a class="lightgallery" href="/images/2020-05-25/bzt2.png#center" title="" data-thumbnail="/images/2020-05-25/bzt2.png#center" data-sub-html="<h2>叛军存在时的消息传递</h2>"><img  loading="lazy" src='/images/2020-05-25/bzt2.png#center'     ></a><figcaption class="image-caption">叛军存在时的消息传递</figcaption>
</figure></p>
<ul>
<li>总共有三个将军，其中一个作为指挥官</li>
<li>通过信使相互传递作战指令，进攻或者撤退</li>
<li>所有忠诚的将军必须执行统一的作战计划，忠诚的将军必须执行忠诚的指挥官发布的指令</li>
<li>假如 LIEUTENANT2 叛变，LIEUTENANT1 收到的作战指令就是“进攻，撤退”</li>
<li>假如 COMMANDER 叛变，LIEUTENANT1 和 LIEUTENANT2 收到的作战指令都是“进攻，撤退”</li>
</ul>
<h3 id="口信消息型解法" class="headerLink">
    <a href="#%e5%8f%a3%e4%bf%a1%e6%b6%88%e6%81%af%e5%9e%8b%e8%a7%a3%e6%b3%95" class="header-mark"></a>口信消息型解法</h3><ul>
<li>叛变人数为 m 需要已知</li>
<li>则所有参与者的人数至少为 3m+1</li>
<li>第一轮由指挥官发送作战指令</li>
<li>第二轮由各位将军相互发送指令</li>
<li>收到指令的将军按照少数服从多数的原则执行指令</li>
<li>按照这个公式，前面的例子叛军为 1 人的情况，则需要 1 个指挥官和 3 个将军</li>
</ul>
<p><figure><a class="lightgallery" href="/images/2020-05-25/bzt3.png#center" title="" data-thumbnail="/images/2020-05-25/bzt3.png#center" data-sub-html="<h2>将军叛变时的共识过程</h2>"><img  loading="lazy" src='/images/2020-05-25/bzt3.png#center'     ></a><figcaption class="image-caption">将军叛变时的共识过程</figcaption>
</figure></p>
<p>假如 LIEUTENANT3 叛变了，那么首先指挥官向各位将军发送“进攻”的指令，由于 3 号将军叛变了，所以最终 1 号将军收到的指令是 2 个进攻，1 个撤退，2 号将军同样收到 2 个进攻，1 个撤退，这样忠诚的将军将会执行一致的指令</p>
<p><figure><a class="lightgallery" href="/images/2020-05-25/bzt4.png#center" title="" data-thumbnail="/images/2020-05-25/bzt4.png#center" data-sub-html="<h2>指挥官叛变时的共识过程</h2>"><img  loading="lazy" src='/images/2020-05-25/bzt4.png#center'     ></a><figcaption class="image-caption">指挥官叛变时的共识过程</figcaption>
</figure></p>
<p>假如 COMMANDER 叛变了，分别向 1 号将军发送了“进攻”，向 2 号将军发送了“撤退”，向 3 号将军发送“进攻”，那么通过第二轮的协商后，1，2，3 号将军得到的指令都是“进攻，进攻，撤退”，这样按照少数服从多数的原则，忠诚的将军最终执行了一致的作战指令。</p>]]></description></item></channel></rss>