<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="replication-semisync-installation">
      </a>
      19.4.10.1 Installing Semisynchronous Replication
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045136241856">
  </a>
  <a class="indexterm" name="idm46045136240352">
  </a>
  <p>
   Semisynchronous replication is implemented using plugins, which
        must be installed on the source and on the replicas to make
        semisynchronous replication available on the instances. There
        are different plugins for a source and for a replica. After a
        plugin has been installed, you control it by means of the system
        variables associated with it. These system variables are
        available only when the associated plugin has been installed.
  </p>
  <p>
   This section describes how to install the semisynchronous
        replication plugins. For general information about installing
        plugins, see
   <a class="xref" href="plugin-loading.html" title="7.6.1 Installing and Uninstalling Plugins">
    Section 7.6.1, “Installing and Uninstalling Plugins”
   </a>
   .
  </p>
  <p>
   To use semisynchronous replication, the following requirements
        must be satisfied:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      The capability of installing plugins requires a MySQL server
            that supports dynamic loading. To verify this, check that
            the value of the
      <a class="link" href="server-system-variables.html#sysvar_have_dynamic_loading">
       <code class="literal">
        have_dynamic_loading
       </code>
      </a>
      system
            variable is
      <code class="literal">
       YES
      </code>
      . Binary distributions
            should support dynamic loading.
     </p>
    </li>
    <li class="listitem">
     <p>
      Replication must already be working, see
      <a class="xref" href="replication-configuration.html" title="19.1 Configuring Replication">
       Section 19.1, “Configuring Replication”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      There must not be multiple replication channels configured.
            Semisynchronous replication is only compatible with the
            default replication channel. See
      <a class="xref" href="replication-channels.html" title="19.2.2 Replication Channels">
       Section 19.2.2, “Replication Channels”
      </a>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   The file name suffix for the plugin library files differs per
        platform (for example,
   <code class="filename">
    .so
   </code>
   for Unix and
        Unix-like systems, and
   <code class="filename">
    .dll
   </code>
   for Windows).
        The plugin and library file names are as follows:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Source server:
      <code class="literal">
       rpl_semi_sync_source
      </code>
      plugin (
      <code class="filename">
       semisync_source.so
      </code>
      or
      <code class="filename">
       semisync_source.dll
      </code>
      library)
     </p>
    </li>
    <li class="listitem">
     <p>
      Replica:
      <code class="literal">
       rpl_semi_sync_replica
      </code>
      plugin
            (
      <code class="filename">
       semisync_replica.so
      </code>
      or
      <code class="filename">
       semisync_replica.dll
      </code>
      library)
     </p>
    </li>
   </ul>
  </div>
  <p>
   To be usable by a source or replica server, the appropriate
        plugin library file must be located in the MySQL plugin
        directory (the directory named by the
   <a class="link" href="server-system-variables.html#sysvar_plugin_dir">
    <code class="literal">
     plugin_dir
    </code>
   </a>
   system variable). If
        necessary, configure the plugin directory location by setting
        the value of
   <a class="link" href="server-system-variables.html#sysvar_plugin_dir">
    <code class="literal">
     plugin_dir
    </code>
   </a>
   at
        server startup. The source plugin library file must be present
        in the plugin directory of the source server. The replica plugin
        library file must be present in the plugin directory of each
        replica server.
  </p>
  <p>
   To set up semisynchronous replication, use the following
        instructions. The
   <a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
    <code class="literal">
     INSTALL PLUGIN
    </code>
   </a>
   ,
   <a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
    <code class="literal">
     SET
        GLOBAL
    </code>
   </a>
   ,
   <a class="link" href="stop-replica.html" title="15.4.2.5 STOP REPLICA Statement">
    <code class="literal">
     STOP REPLICA
    </code>
   </a>
   ,
        and
   <a class="link" href="start-replica.html" title="15.4.2.4 START REPLICA Statement">
    <code class="literal">
     START REPLICA
    </code>
   </a>
   statements
        mentioned here require the
   <a class="link" href="privileges-provided.html#priv_replication-slave-admin">
    <code class="literal">
     REPLICATION_SLAVE_ADMIN
    </code>
   </a>
   privilege
        (or the deprecated
   <a class="link" href="privileges-provided.html#priv_super">
    <code class="literal">
     SUPER
    </code>
   </a>
   privilege).
  </p>
  <p>
   To load the plugins, use the
   <a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
    <code class="literal">
     INSTALL
        PLUGIN
    </code>
   </a>
   statement on the source and on each replica
        that is to be semisynchronous, adjusting the
   <code class="filename">
    .so
   </code>
   suffix for your platform as necessary.
  </p>
  <p>
   On the source:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa78929210"><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"><span class="token keyword">INSTALL</span> <span class="token keyword">PLUGIN</span> rpl_semi_sync_source <span class="token keyword">SONAME</span> <span class="token string">'semisync_source.so'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   On each replica:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa13748812"><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"><span class="token keyword">INSTALL</span> <span class="token keyword">PLUGIN</span> rpl_semi_sync_replica <span class="token keyword">SONAME</span> <span class="token string">'semisync_replica.so'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   If an attempt to install a plugin results in an error on Linux
        similar to that shown here, you must install
   <code class="literal">
    libimf
   </code>
   :
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa81280878"><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"><span class="token prompt">mysql&gt;</span> <span class="token keyword">INSTALL</span> <span class="token keyword">PLUGIN</span> rpl_semi_sync_source <span class="token keyword">SONAME</span> <span class="token string">'semisync_source.so'</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1126 (HY000)<span class="token punctuation">:</span> Can't open shared library
'/usr/local/mysql/lib/plugin/semisync_source.so'
(errno<span class="token punctuation">:</span> 22 libimf.so<span class="token punctuation">:</span> cannot open shared object file<span class="token punctuation">:</span>
No such file or directory)</span></code></pre>
  </div>
  <p>
   You can obtain
   <code class="literal">
    libimf
   </code>
   from
   <a class="ulink" href="https://dev.mysql.com/downloads/os-linux.html" target="_top">
    https://dev.mysql.com/downloads/os-linux.html
   </a>
   .
  </p>
  <p>
   To verify plugin installation, examine the Information Schema
   <a class="link" href="information-schema-plugins-table.html" title="28.3.22 The INFORMATION_SCHEMA PLUGINS Table">
    <code class="literal">
     PLUGINS
    </code>
   </a>
   table or use the
   <a class="link" href="show-plugins.html" title="15.7.7.27 SHOW PLUGINS Statement">
    <code class="literal">
     SHOW PLUGINS
    </code>
   </a>
   statement (see
   <a class="xref" href="obtaining-plugin-information.html" title="7.6.2 Obtaining Server Plugin Information">
    Section 7.6.2, “Obtaining Server Plugin Information”
   </a>
   ). For example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa70914785"><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"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> PLUGIN_NAME<span class="token punctuation">,</span> PLUGIN_STATUS
       <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span><span class="token keyword">PLUGINS</span>
       <span class="token keyword">WHERE</span> PLUGIN_NAME <span class="token operator">LIKE</span> <span class="token string">'%semi%'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> PLUGIN_NAME          <span class="token punctuation">|</span> PLUGIN_STATUS <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> rpl_semi_sync_source <span class="token punctuation">|</span> ACTIVE        <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
  </div>
  <p>
   If a plugin fails to initialize, check the server error log for
        diagnostic messages.
  </p>
  <p>
   After a semisynchronous replication plugin has been installed,
        it is disabled by default. The plugins must be enabled both on
        the source side and the replica side to enable semisynchronous
        replication. If only one side is enabled, replication is
        asynchronous. To enable the plugins, set the appropriate system
        variable either at runtime using
   <a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
    <code class="literal">
     SET
        GLOBAL
    </code>
   </a>
   , or at server startup on the command line or in
        an option file. For example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa50179445"><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"><span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> rpl_semi_sync_source_enabled <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span></code></pre>
  </div>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa88396607"><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"><span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> rpl_semi_sync_replica_enabled <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   If you enable semisynchronous replication on a replica at
        runtime, you must also start the replication I/O (receiver)
        thread (stopping it first if it is already running) to cause the
        replica to connect to the source and register as a
        semisynchronous replica:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa81141087"><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"><span class="token keyword">STOP</span> <span class="token keyword">REPLICA</span> <span class="token keyword">IO_THREAD</span><span class="token punctuation">;</span>
<span class="token keyword">START</span> <span class="token keyword">REPLICA</span> <span class="token keyword">IO_THREAD</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   If the replication I/O (receiver) thread is already running and
        you do not restart it, the replica continues to use asynchronous
        replication.
  </p>
  <p>
   A setting listed in an option file takes effect each time the
        server starts. For example, you can set the variables in
   <code class="filename">
    my.cnf
   </code>
   files on the source and replica
        servers as follows. On the source:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa6313411"><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-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">rpl_semi_sync_source_enabled</span><span class="token attr-value"><span class="token punctuation">=</span>1</span></code></pre>
  </div>
  <p>
   On each replica:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa87996701"><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-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">rpl_semi_sync_replica_enabled</span><span class="token attr-value"><span class="token punctuation">=</span>1</span></code></pre>
  </div>
  <p>
   You can configure the behavior of the semisynchronous
        replication plugins using the system variables that become
        available when you install the plugins. For information on key
        system variables, see
   <a class="xref" href="replication-semisync-interface.html" title="19.4.10.2 Configuring Semisynchronous Replication">
    Section 19.4.10.2, “Configuring Semisynchronous Replication”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
