<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="group-replication-deploying-locally">
      </a>
      20.2.2 Deploying Group Replication Locally
     </h3>
    </div>
   </div>
  </div>
  <p>
   The most common way to deploy Group Replication is using multiple
      server instances, to provide high availability. It is also
      possible to deploy Group Replication locally, for example for
      testing purposes. This section explains how you can deploy Group
      Replication locally.
  </p>
  <div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Important
   </div>
   <p>
    Group Replication is usually deployed on multiple hosts because
        this ensures that high-availability is provided. The
        instructions in this section are not suitable for production
        deployments because all MySQL server instances are running on
        the same single host. In the event of failure of this host, the
        whole group fails. Therefore this information should be used for
        testing purposes and it should not be used in a production
        environments.
   </p>
  </div>
  <p>
   This section explains how to create a replication group with three
      MySQL Server instances on one physical machine. This means that
      three data directories are needed, one per server instance, and
      that you need to configure each instance independently. This -
      procedure assumes that MySQL Server was downloaded and unpacked -
      into the directory named
   <code class="literal">
    mysql-8.4
   </code>
   . Each MySQL server
      instance requires a specific data directory. Create a directory
      named
   <code class="literal">
    data
   </code>
   , then in that directory create a
      subdirectory for each server instance, for example s1, s2 and s3,
      and initialize each one.
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa78159816"><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">mysql-8<span class="token punctuation">.</span>4/bin/mysqld <span class="token property">--initialize-insecure</span> <span class="token constant">--basedir</span><span class="token attr-value"><span class="token punctuation">=</span>$PWD/mysql-8.4</span> <span class="token constant">--datadir</span><span class="token attr-value"><span class="token punctuation">=</span>$PWD/data/s1</span>
mysql-8<span class="token punctuation">.</span>4/bin/mysqld <span class="token property">--initialize-insecure</span> <span class="token constant">--basedir</span><span class="token attr-value"><span class="token punctuation">=</span>$PWD/mysql-8.4</span> <span class="token constant">--datadir</span><span class="token attr-value"><span class="token punctuation">=</span>$PWD/data/s2</span>
mysql-8<span class="token punctuation">.</span>4/bin/mysqld <span class="token property">--initialize-insecure</span> <span class="token constant">--basedir</span><span class="token attr-value"><span class="token punctuation">=</span>$PWD/mysql-8.4</span> <span class="token constant">--datadir</span><span class="token attr-value"><span class="token punctuation">=</span>$PWD/data/s3</span></code></pre>
  </div>
  <p>
   Inside
   <code class="literal">
    data/s1
   </code>
   ,
   <code class="literal">
    data/s2
   </code>
   ,
   <code class="literal">
    data/s3
   </code>
   is an initialized data directory,
      containing the mysql system database and related tables and much
      more. To learn more about the initialization procedure, see
   <a class="xref" href="data-directory-initialization.html" title="2.9.1 Initializing the Data Directory">
    Section 2.9.1, “Initializing the Data Directory”
   </a>
   .
  </p>
  <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Warning
   </div>
   <p>
    Do not use
    <code class="literal">
     -initialize-insecure
    </code>
    in production
        environments, it is only used here to simplify the tutorial. For
        more information on security settings, see
    <a class="xref" href="group-replication-security.html" title="20.6 Group Replication Security">
     Section 20.6, “Group Replication Security”
    </a>
    .
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="configure-local-group-members">
       </a>
       Configuration of Local Group Replication Members
      </h4>
     </div>
    </div>
   </div>
   <p>
    When you are following
    <a class="xref" href="group-replication-configuring-instances.html" title="20.2.1.2 Configuring an Instance for Group Replication">
     Section 20.2.1.2, “Configuring an Instance for Group Replication”
    </a>
    , you
        need to add configuration for the data directories added in the
        previous section. For example:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa20631903"><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 comment" spellcheck="true"># server configuration</span>
<span class="token constant">datadir</span><span class="token attr-value"><span class="token punctuation">=</span>&lt;full_path_to_data&gt;/data/s1</span>
<span class="token constant">basedir</span><span class="token attr-value"><span class="token punctuation">=</span>&lt;full_path_to_bin&gt;/mysql-8.4/</span>

<span class="token constant">port</span><span class="token attr-value"><span class="token punctuation">=</span>24801</span>
<span class="token constant">socket</span><span class="token attr-value"><span class="token punctuation">=</span>&lt;full_path_to_sock_dir&gt;/s1.sock</span></code></pre>
   </div>
   <p>
    These settings configure MySQL server to use the data directory
        created earlier and which port the server should open and start
        listening for incoming connections.
   </p>
   <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
    <div class="admon-title">
     Note
    </div>
    <p>
     The non-default port of 24801 is used because in this tutorial
          the three server instances use the same hostname. In a setup
          with three different machines this would not be required.
    </p>
   </div>
   <p>
    Group Replication requires a network connection between the
        members, which means that each member must be able to resolve
        the network address of all of the other members. For example in
        this tutorial all three instances run on one machine, so to
        ensure that the members can contact each other you could add a
        line to the option file such as
    <a class="link" href="replication-options-replica.html#sysvar_report_host">
     <code class="literal">
      report_host=127.0.0.1
     </code>
    </a>
    .
   </p>
   <p>
    Then each member needs to be able to connect to the other
        members on their
    <a class="link" href="group-replication-system-variables.html#sysvar_group_replication_local_address">
     <code class="literal">
      group_replication_local_address
     </code>
    </a>
    .
        For example in the option file of member s1 add:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa38560065"><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 constant">group_replication_local_address</span><span class="token attr-value"><span class="token punctuation">=</span> "127.0.0.1:24901"</span>
<span class="token constant">group_replication_group_seeds</span><span class="token attr-value"><span class="token punctuation">=</span> "127.0.0.1:24901,127.0.0.1:24902,127.0.0.1:24903"</span></code></pre>
   </div>
   <p>
    This configures s1 to use port 24901 for internal group
        communication with seed members. For each server instance you
        want to add to the group, make these changes in the option file
        of the member. For each member you must ensure a unique address
        is specified, so use a unique port per instance for
    <a class="link" href="group-replication-system-variables.html#sysvar_group_replication_local_address">
     <code class="literal">
      group_replication_local_address
     </code>
    </a>
    .
        Usually you want all members to be able to serve as seeds for
        members that are joining the group and have not got the
        transactions processed by the group. In this case, add all of
        the ports to
    <a class="link" href="group-replication-system-variables.html#sysvar_group_replication_group_seeds">
     <code class="literal">
      group_replication_group_seeds
     </code>
    </a>
    as shown above.
   </p>
   <p>
    The remaining steps of
    <a class="xref" href="group-replication-deploying-in-single-primary-mode.html" title="20.2.1 Deploying Group Replication in Single-Primary Mode">
     Section 20.2.1, “Deploying Group Replication in Single-Primary Mode”
    </a>
    apply equally to a group which you have deployed locally in this
        way.
   </p>
  </div>
 </div>
 <br/>
</div>
