<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="replication-howto">
      </a>
      19.1.2 Setting Up Binary Log File Position Based Replication
     </h3>
    </div>
   </div>
  </div>
  <div class="toc">
   <dl class="toc">
    <dt>
     <span class="section">
      <a href="replication-howto-masterbaseconfig.html">
       19.1.2.1 Setting the Replication Source Configuration
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="replication-howto-slavebaseconfig.html">
       19.1.2.2 Setting the Replica Configuration
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="replication-howto-repuser.html">
       19.1.2.3 Creating a User for Replication
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="replication-howto-masterstatus.html">
       19.1.2.4 Obtaining the Replication Source Binary Log Coordinates
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="replication-snapshot-method.html">
       19.1.2.5 Choosing a Method for Data Snapshots
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="replication-setup-replicas.html">
       19.1.2.6 Setting Up Replicas
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="replication-howto-slaveinit.html">
       19.1.2.7 Setting the Source Configuration on the Replica
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="replication-howto-additionalslaves.html">
       19.1.2.8 Adding Replicas to a Replication Environment
      </a>
     </span>
    </dt>
   </dl>
  </div>
  <p>
   This section describes how to set up a MySQL server to use binary
      log file position based replication. There are a number of
      different methods for setting up replication, and the exact method
      to use depends on how you are setting up replication, and whether
      you already have data in the database on the source that you want
      to replicate.
  </p>
  <div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Tip
   </div>
   <p>
    To deploy multiple instances of MySQL, you can use
    <a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-innodb-cluster.html" target="_top">
     InnoDB Cluster
    </a>
    which enables you to easily administer a group of MySQL server instances in
    <a class="ulink" href="/doc/mysql-shell/8.4/en/" target="_top">
     MySQL Shell
    </a>
    . InnoDB Cluster wraps MySQL Group Replication in a programmatic environment that enables you easily deploy a cluster of MySQL instances to achieve high availability. In addition, InnoDB Cluster interfaces seamlessly with
    <a class="ulink" href="/doc/mysql-router/8.4/en/" target="_top">
     MySQL Router
    </a>
    , which enables your applications to connect to the cluster without writing your own failover process. For similar use cases that do not require high availability, however, you can use
    <a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-innodb-replicaset.html" target="_top">
     InnoDB ReplicaSet
    </a>
    . Installation instructions for MySQL Shell can be found
    <a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-shell-install.html" target="_top">
     here
    </a>
    .
   </p>
  </div>
  <p>
   There are some generic tasks that are common to all setups:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      On the source, you must ensure that binary logging is enabled,
          and configure a unique server ID. This might require a server
          restart. See
      <a class="xref" href="replication-howto-masterbaseconfig.html" title="19.1.2.1 Setting the Replication Source Configuration">
       Section 19.1.2.1, “Setting the Replication Source Configuration”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      On each replica that you want to connect to the source, you
          must configure a unique server ID. This might require a server
          restart. See
      <a class="xref" href="replication-howto-slavebaseconfig.html" title="19.1.2.2 Setting the Replica Configuration">
       Section 19.1.2.2, “Setting the Replica Configuration”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Optionally, create a separate user for your replicas to use
          during authentication with the source when reading the binary
          log for replication. See
      <a class="xref" href="replication-howto-repuser.html" title="19.1.2.3 Creating a User for Replication">
       Section 19.1.2.3, “Creating a User for Replication”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Before creating a data snapshot or starting the replication
          process, on the source you should record the current position
          in the binary log. You need this information when configuring
          the replica so that the replica knows where within the binary
          log to start executing events. See
      <a class="xref" href="replication-howto-masterstatus.html" title="19.1.2.4 Obtaining the Replication Source Binary Log Coordinates">
       Section 19.1.2.4, “Obtaining the Replication Source Binary Log Coordinates”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      If you already have data on the source and want to use it to
          synchronize the replica, you need to create a data snapshot to
          copy the data to the replica. The storage engine you are using
          has an impact on how you create the snapshot. When you are
          using
      <a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
       <code class="literal">
        MyISAM
       </code>
      </a>
      , you must stop
          processing statements on the source to obtain a read-lock,
          then obtain its current binary log coordinates and dump its
          data, before permitting the source to continue executing
          statements. If you do not stop the execution of statements,
          the data dump and the source status information become
          mismatched, resulting in inconsistent or corrupted databases
          on the replicas. For more information on replicating a
      <a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
       <code class="literal">
        MyISAM
       </code>
      </a>
      source, see
      <a class="xref" href="replication-howto-masterstatus.html" title="19.1.2.4 Obtaining the Replication Source Binary Log Coordinates">
       Section 19.1.2.4, “Obtaining the Replication Source Binary Log Coordinates”
      </a>
      . If you are
          using
      <a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
       <code class="literal">
        InnoDB
       </code>
      </a>
      , you do not need a
          read-lock and a transaction that is long enough to transfer
          the data snapshot is sufficient. For more information, see
      <a class="xref" href="innodb-and-mysql-replication.html" title="17.19 InnoDB and MySQL Replication">
       Section 17.19, “InnoDB and MySQL Replication”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Configure the replica with settings for connecting to the
          source, such as the host name, login credentials, and binary
          log file name and position. See
      <a class="xref" href="replication-howto-slaveinit.html" title="19.1.2.7 Setting the Source Configuration on the Replica">
       Section 19.1.2.7, “Setting the Source Configuration on the Replica”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Implement replication-specific security measures on the
          sources and replicas as appropriate for your system. See
      <a class="xref" href="replication-security.html" title="19.3 Replication Security">
       Section 19.3, “Replication Security”
      </a>
      .
     </p>
    </li>
   </ul>
  </div>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    Certain steps within the setup process require the
    <a class="link" href="privileges-provided.html#priv_super">
     <code class="literal">
      SUPER
     </code>
    </a>
    privilege. If you do not
        have this privilege, it might not be possible to enable
        replication.
   </p>
  </div>
  <p>
   After configuring the basic options, select your scenario:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      To set up replication for a fresh installation of a source and
          replicas that contain no data, see
      <a class="xref" href="replication-setup-replicas.html#replication-howto-newservers" title="19.1.2.6.1 Setting Up Replication with New Source and Replicas">
       Section 19.1.2.6.1, “Setting Up Replication with New Source and Replicas”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      To set up replication of a new source using the data from an
          existing MySQL server, see
      <a class="xref" href="replication-setup-replicas.html#replication-howto-existingdata" title="19.1.2.6.2 Setting Up Replication with Existing Data">
       Section 19.1.2.6.2, “Setting Up Replication with Existing Data”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      To add replicas to an existing replication environment, see
      <a class="xref" href="replication-howto-additionalslaves.html" title="19.1.2.8 Adding Replicas to a Replication Environment">
       Section 19.1.2.8, “Adding Replicas to a Replication Environment”
      </a>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   Before administering MySQL replication servers, read this entire
      chapter and try all statements mentioned in
   <a class="xref" href="replication-statements-source.html" title="15.4.1 SQL Statements for Controlling Source Servers">
    Section 15.4.1, “SQL Statements for Controlling Source Servers”
   </a>
   , and
   <a class="xref" href="replication-statements-replica.html" title="15.4.2 SQL Statements for Controlling Replica Servers">
    Section 15.4.2, “SQL Statements for Controlling Replica Servers”
   </a>
   . Also familiarize
      yourself with the replication startup options described in
   <a class="xref" href="replication-options.html" title="19.1.6 Replication and Binary Logging Options and Variables">
    Section 19.1.6, “Replication and Binary Logging Options and Variables”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
