<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="mysql-cluster-replication-two-channels">
      </a>
      25.7.7 Using Two Replication Channels for NDB Cluster Replication
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045086048960">
  </a>
  <a class="indexterm" name="idm46045086047504">
  </a>
  <p>
   In a more complete example scenario, we envision two replication
      channels to provide redundancy and thereby guard against possible
      failure of a single replication channel. This requires a total of
      four replication servers, two source servers on the source cluster
      and two replica servers on the replica cluster. For purposes of
      the discussion that follows, we assume that unique identifiers are
      assigned as shown here:
  </p>
  <div class="table">
   <a name="idm46045086045152">
   </a>
   <p class="title">
    <b>
     Table 25.45 NDB Cluster replication servers described in the text
    </b>
   </p>
   <div class="table-contents">
    <table>
     <colgroup>
      <col style="width: 25%"/>
      <col style="width: 75%"/>
     </colgroup>
     <thead>
      <tr>
       <th>
        Server ID
       </th>
       <th>
        Description
       </th>
      </tr>
     </thead>
     <tbody>
      <tr>
       <td>
        1
       </td>
       <td>
        Source - primary replication channel (
        <span class="emphasis">
         <em>
          S
         </em>
        </span>
        )
       </td>
      </tr>
      <tr>
       <td>
        2
       </td>
       <td>
        Source - secondary replication channel (
        <span class="emphasis">
         <em>
          S'
         </em>
        </span>
        )
       </td>
      </tr>
      <tr>
       <td>
        3
       </td>
       <td>
        Replica - primary replication channel (
        <span class="emphasis">
         <em>
          R
         </em>
        </span>
        )
       </td>
      </tr>
      <tr>
       <td>
        4
       </td>
       <td>
        replica - secondary replication channel (
        <span class="emphasis">
         <em>
          R'
         </em>
        </span>
        )
       </td>
      </tr>
     </tbody>
    </table>
   </div>
  </div>
  <br class="table-break"/>
  <p>
   Setting up replication with two channels is not radically
      different from setting up a single replication channel. First, the
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   processes for the primary and secondary
      replication source servers must be started, followed by those for
      the primary and secondary replicas. The replication processes can
      be initiated by issuing the
   <a class="link" href="start-replica.html" title="15.4.2.4 START REPLICA Statement">
    <code class="literal">
     START
      REPLICA
    </code>
   </a>
   statement on each of the replicas. The commands
      and the order in which they need to be issued are shown here:
  </p>
  <div class="orderedlist">
   <ol class="orderedlist" type="1">
    <li class="listitem">
     <p>
      Start the primary replication source:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa14814670"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">shell<em class="replaceable">S</em>&gt;</span><span class="token command"> mysqld</span> <span class="token property">--ndbcluster</span> <span class="token constant">--server-id</span><span class="token attr-value"><span class="token punctuation">=</span>1</span> \
               <span class="token property">--log-bin</span> &amp;</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Start the secondary replication source:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa58196577"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">shell<em class="replaceable">S'</em>&gt; mysqld <span class="token property">--ndbcluster</span> <span class="token constant">--server-id</span><span class="token attr-value"><span class="token punctuation">=</span>2</span> \
               <span class="token property">--log-bin</span> &amp;</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Start the primary replica server:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa27168405"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">shell<em class="replaceable">R</em>&gt; mysqld <span class="token property">--ndbcluster</span> <span class="token constant">--server-id</span><span class="token attr-value"><span class="token punctuation">=</span>3</span> \
               <span class="token property">--skip-replica-start</span> &amp;</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Start the secondary replica server:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa54321663"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">shell<em class="replaceable">R'</em>&gt; mysqld <span class="token property">--ndbcluster</span> <span class="token constant">--server-id</span><span class="token attr-value"><span class="token punctuation">=</span>4</span> \
                <span class="token property">--skip-replica-start</span> &amp;</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Finally, initiate replication on the primary channel by
          executing the
      <a class="link" href="start-replica.html" title="15.4.2.4 START REPLICA Statement">
       <code class="literal">
        START REPLICA
       </code>
      </a>
      statement on the primary replica as shown here:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa85061599"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">mysql<em class="replaceable">R</em><span class="token operator">&gt;</span> <span class="token keyword">START</span> <span class="token keyword">REPLICA</span><span class="token punctuation">;</span></code></pre>
     </div>
     <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
      <div class="admon-title">
       Warning
      </div>
      <p>
       Only the primary channel must be started at this point. The
            secondary replication channel needs to be started only in
            the event that the primary replication channel fails, as
            described in
       <a class="xref" href="mysql-cluster-replication-failover.html" title="25.7.8 Implementing Failover with NDB Cluster Replication">
        Section 25.7.8, “Implementing Failover with NDB Cluster Replication”
       </a>
       .
            Running multiple replication channels simultaneously can
            result in unwanted duplicate records being created on the
            replicas.
      </p>
     </div>
    </li>
   </ol>
  </div>
  <p>
   As mentioned previously, it is not necessary to enable binary
      logging on the replicas.
  </p>
 </div>
 <br/>
</div>
