<div id="docs-body">
 <div class="chapter">
  <div class="titlepage">
   <div>
    <div>
     <h1 class="title">
      <a name="replication">
      </a>
      Chapter 19 Replication
     </h1>
    </div>
   </div>
  </div>
  <div class="toc">
   <p>
    <b>
     Table of Contents
    </b>
   </p>
   <dl class="toc">
    <dt>
     <span class="section">
      <a href="replication-configuration.html">
       19.1 Configuring Replication
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="binlog-replication-configuration-overview.html">
         19.1.1 Binary Log File Position Based Replication Configuration Overview
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-howto.html">
         19.1.2 Setting Up Binary Log File Position Based Replication
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-gtids.html">
         19.1.3 Replication with Global Transaction Identifiers
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-mode-change-online.html">
         19.1.4 Changing GTID Mode on Online Servers
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-multi-source.html">
         19.1.5 MySQL Multi-Source Replication
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-options.html">
         19.1.6 Replication and Binary Logging Options and Variables
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-administration.html">
         19.1.7 Common Replication Administration Tasks
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="replication-implementation.html">
       19.2 Replication Implementation
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="replication-formats.html">
         19.2.1 Replication Formats
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-channels.html">
         19.2.2 Replication Channels
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-threads.html">
         19.2.3 Replication Threads
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replica-logs.html">
         19.2.4 Relay Log and Replication Metadata Repositories
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-rules.html">
         19.2.5 How Servers Evaluate Replication Filtering Rules
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="replication-security.html">
       19.3 Replication Security
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="replication-encrypted-connections.html">
         19.3.1 Setting Up Replication to Use Encrypted Connections
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-binlog-encryption.html">
         19.3.2 Encrypting Binary Log Files and Relay Log Files
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-privilege-checks.html">
         19.3.3 Replication Privilege Checks
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="replication-solutions.html">
       19.4 Replication Solutions
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="replication-solutions-backups.html">
         19.4.1 Using Replication for Backups
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-solutions-unexpected-replica-halt.html">
         19.4.2 Handling an Unexpected Halt of a Replica
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-solutions-rbr-monitoring.html">
         19.4.3 Monitoring Row-based Replication
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-solutions-diffengines.html">
         19.4.4 Using Replication with Different Source and Replica Storage Engines
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-solutions-scaleout.html">
         19.4.5 Using Replication for Scale-Out
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-solutions-partitioning.html">
         19.4.6 Replicating Different Databases to Different Replicas
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-solutions-performance.html">
         19.4.7 Improving Replication Performance
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-solutions-switch.html">
         19.4.8 Switching Sources During Failover
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-asynchronous-connection-failover.html">
         19.4.9 Switching Sources and Replicas with Asynchronous Connection Failover
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-semisync.html">
         19.4.10 Semisynchronous Replication
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-delayed.html">
         19.4.11 Delayed Replication
        </a>
       </span>
      </dt>
     </dl>
    </dd>
    <dt>
     <span class="section">
      <a href="replication-notes.html">
       19.5 Replication Notes and Tips
      </a>
     </span>
    </dt>
    <dd>
     <dl>
      <dt>
       <span class="section">
        <a href="replication-features.html">
         19.5.1 Replication Features and Issues
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-compatibility.html">
         19.5.2 Replication Compatibility Between MySQL Versions
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-upgrade.html">
         19.5.3 Upgrading or Downgrading a Replication Topology
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-problems.html">
         19.5.4 Troubleshooting Replication
        </a>
       </span>
      </dt>
      <dt>
       <span class="section">
        <a href="replication-bugs.html">
         19.5.5 How to Report Replication Bugs or Problems
        </a>
       </span>
      </dt>
     </dl>
    </dd>
   </dl>
  </div>
  <a class="indexterm" name="idm46045146901792">
  </a>
  <a class="indexterm" name="idm46045146900720">
  </a>
  <a class="indexterm" name="idm46045146899232">
  </a>
  <a class="indexterm" name="idm46045146897728">
  </a>
  <p>
   Replication enables data from one MySQL database server (known as a
    source) to be copied to one or more MySQL database servers (known as
    replicas). Replication is asynchronous by default; replicas do not
    need to be connected permanently to receive updates from a source.
    Depending on the configuration, you can replicate all databases,
    selected databases, or even selected tables within a database.
  </p>
  <p>
   Advantages of replication in MySQL include:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Scale-out solutions - spreading the load among multiple replicas
        to improve performance. In this environment, all writes and
        updates must take place on the source server. Reads, however,
        may take place on one or more replicas. This model can improve
        the performance of writes (since the source is dedicated to
        updates), while dramatically increasing read speed across an
        increasing number of replicas.
     </p>
    </li>
    <li class="listitem">
     <p>
      Data security - because the replica can pause the replication
        process, it is possible to run backup services on the replica
        without corrupting the corresponding source data.
     </p>
    </li>
    <li class="listitem">
     <p>
      Analytics - live data can be created on the source, while the
        analysis of the information can take place on the replica
        without affecting the performance of the source.
     </p>
    </li>
    <li class="listitem">
     <p>
      Long-distance data distribution - you can use replication to
        create a local copy of data for a remote site to use, without
        permanent access to the source.
     </p>
    </li>
   </ul>
  </div>
  <p>
   For information on how to use replication in such scenarios, see
   <a class="xref" href="replication-solutions.html" title="19.4 Replication Solutions">
    Section 19.4, “Replication Solutions”
   </a>
   .
  </p>
  <p>
   MySQL 8.4 supports different methods of replication.
    The traditional method is based on replicating events from the
    source's binary log, and requires the log files and positions in
    them to be synchronized between source and replica. The newer method
    based on
   <span class="firstterm">
    global transaction
    identifiers
   </span>
   (GTIDs) is transactional and therefore does
    not require working with log files or positions within these files,
    which greatly simplifies many common replication tasks. Replication
    using GTIDs guarantees consistency between source and replica as
    long as all transactions committed on the source have also been
    applied on the replica. For more information about GTIDs and
    GTID-based replication in MySQL, see
   <a class="xref" href="replication-gtids.html" title="19.1.3 Replication with Global Transaction Identifiers">
    Section 19.1.3, “Replication with Global Transaction Identifiers”
   </a>
   . For information on using binary
    log file position based replication, see
   <a class="xref" href="replication-configuration.html" title="19.1 Configuring Replication">
    Section 19.1, “Configuring Replication”
   </a>
   .
  </p>
  <p>
   Replication in MySQL supports different types of synchronization.
    The original type of synchronization is one-way, asynchronous
    replication, in which one server acts as the source, while one or
    more other servers act as replicas. This is in contrast to the
   <span class="emphasis">
    <em>
     synchronous
    </em>
   </span>
   replication which is a
    characteristic of NDB Cluster (see
   <a class="xref" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
    Chapter 25,
    <i>
     MySQL NDB Cluster 8.4
    </i>
   </a>
   ).
    In MySQL 8.4, semisynchronous replication is supported
    in addition to the built-in asynchronous replication. With
    semisynchronous replication, a commit performed on the source blocks
    before returning to the session that performed the transaction until
    at least one replica acknowledges that it has received and logged
    the events for the transaction; see
   <a class="xref" href="replication-semisync.html" title="19.4.10 Semisynchronous Replication">
    Section 19.4.10, “Semisynchronous Replication”
   </a>
   . MySQL 8.4 also
    supports delayed replication such that a replica deliberately lags
    behind the source by at least a specified amount of time; see
   <a class="xref" href="replication-delayed.html" title="19.4.11 Delayed Replication">
    Section 19.4.11, “Delayed Replication”
   </a>
   . For scenarios where
   <span class="emphasis">
    <em>
     synchronous
    </em>
   </span>
   replication is required, use NDB
    Cluster (see
   <a class="xref" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
    Chapter 25,
    <i>
     MySQL NDB Cluster 8.4
    </i>
   </a>
   ).
  </p>
  <p>
   There are a number of solutions available for setting up replication
    between servers, and the best method to use depends on the presence
    of data and the engine types you are using. For more information on
    the available options, see
   <a class="xref" href="replication-howto.html" title="19.1.2 Setting Up Binary Log File Position Based Replication">
    Section 19.1.2, “Setting Up Binary Log File Position Based Replication”
   </a>
   .
  </p>
  <p>
   There are two core types of replication format, Statement Based
    Replication (SBR), which replicates entire SQL statements, and Row
    Based Replication (RBR), which replicates only the changed rows. You
    can also use a third variety, Mixed Based Replication (MBR). For
    more information on the different replication formats, see
   <a class="xref" href="replication-formats.html" title="19.2.1 Replication Formats">
    Section 19.2.1, “Replication Formats”
   </a>
   .
  </p>
  <p>
   Replication is controlled through a number of different options and
    variables. For more information, see
   <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>
   . Additional security measures
    can be applied to a replication topology, as described in
   <a class="xref" href="replication-security.html" title="19.3 Replication Security">
    Section 19.3, “Replication Security”
   </a>
   .
  </p>
  <p>
   You can use replication to solve a number of different problems,
    including performance, supporting the backup of different databases,
    and as part of a larger solution to alleviate system failures. For
    information on how to address these issues, see
   <a class="xref" href="replication-solutions.html" title="19.4 Replication Solutions">
    Section 19.4, “Replication Solutions”
   </a>
   .
  </p>
  <p>
   For notes and tips on how different data types and statements are
    treated during replication, including details of replication
    features, version compatibility, upgrades, and potential problems
    and their resolution, see
   <a class="xref" href="replication-notes.html" title="19.5 Replication Notes and Tips">
    Section 19.5, “Replication Notes and Tips”
   </a>
   . For
    answers to some questions often asked by those who are new to MySQL
    Replication, see
   <a class="xref" href="faqs-replication.html" title="A.14 MySQL 8.4 FAQ: Replication">
    Section A.14, “MySQL 8.4 FAQ: Replication”
   </a>
   .
  </p>
  <p>
   For detailed information on the implementation of replication, how
    replication works, the process and contents of the binary log,
    background threads and the rules used to decide how statements are
    recorded and replicated, see
   <a class="xref" href="replication-implementation.html" title="19.2 Replication Implementation">
    Section 19.2, “Replication Implementation”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
