<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="replication-howto-masterstatus">
      </a>
      19.1.2.4 Obtaining the Replication Source Binary Log Coordinates
     </h4>
    </div>
   </div>
  </div>
  <p>
   To configure the replica to start the replication process at the
        correct point, you need to note the source's current coordinates
        within its binary log.
  </p>
  <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Warning
   </div>
   <p>
    This procedure uses
    <a class="link" href="flush.html#flush-tables-with-read-lock">
     <code class="literal">
      FLUSH TABLES WITH
          READ LOCK
     </code>
    </a>
    , which blocks
    <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
     <code class="literal">
      COMMIT
     </code>
    </a>
    operations for
    <a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
     <code class="literal">
      InnoDB
     </code>
    </a>
    tables.
   </p>
  </div>
  <p>
   If you are planning to shut down the source to create a data
        snapshot, you can optionally skip this procedure and instead
        store a copy of the binary log index file along with the data
        snapshot. In that situation, the source creates a new binary log
        file on restart. The source binary log coordinates where the
        replica must start the replication process are therefore the
        start of that new file, which is the next binary log file on the
        source following after the files that are listed in the copied
        binary log index file.
  </p>
  <p>
   To obtain the source binary log coordinates, follow these steps:
  </p>
  <div class="orderedlist">
   <ol class="orderedlist" type="1">
    <li class="listitem">
     <p>
      Start a session on the source by connecting to it with the
            command-line client, and flush all tables and block write
            statements by executing the
      <a class="link" href="flush.html#flush-tables-with-read-lock">
       <code class="literal">
        FLUSH
            TABLES WITH READ LOCK
       </code>
      </a>
      statement:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa27580345"><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">FLUSH</span> <span class="token keyword">TABLES</span> <span class="token keyword">WITH</span> <span class="token keyword">READ</span> <span class="token keyword">LOCK</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>
       Leave the client from which you issued the
       <a class="link" href="flush.html#flush-tables">
        <code class="literal">
         FLUSH TABLES
        </code>
       </a>
       statement
              running so that the read lock remains in effect. If you
              exit the client, the lock is released.
      </p>
     </div>
    </li>
    <li class="listitem">
     <p>
      In a different session on the source, use the
      <a class="link" href="show-binary-log-status.html" title="15.7.7.1 SHOW BINARY LOG STATUS Statement">
       <code class="literal">
        SHOW BINARY LOG STATUS
       </code>
      </a>
      statement to determine the current binary log file name and
            position:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa68446605"><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">SHOW</span> <span class="token datatype">BINARY</span> LOG <span class="token keyword">STATUS</span>\G
<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> 1. row <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>
             File<span class="token punctuation">:</span> mysql-bin.000003
         Position<span class="token punctuation">:</span> 73
     Binlog_Do_DB<span class="token punctuation">:</span> test
 Binlog_Ignore_DB<span class="token punctuation">:</span> manual, mysql
Executed_Gtid_Set<span class="token punctuation">:</span> 3E11FA47-71CA-11E1-9E33-C80AA9429562<span class="token punctuation">:</span>1-5
</span><span class="token output">1 row in set (0.00 sec)</span></code></pre>
     </div>
     <p>
      The
      <code class="literal">
       File
      </code>
      column shows the name of the log
            file and the
      <code class="literal">
       Position
      </code>
      column shows the
            position within the file. In this example, the binary log
            file is
      <code class="literal">
       mysql-bin.000003
      </code>
      and the position
            is 73. Record these values. You need them later when you are
            setting up the replica. They represent the replication
            coordinates at which the replica should begin processing new
            updates from the source.
     </p>
     <p>
      If the source has been running previously with binary
            logging disabled, the log file name and position values
            displayed by
      <a class="link" href="show-binary-log-status.html" title="15.7.7.1 SHOW BINARY LOG STATUS Statement">
       <code class="literal">
        SHOW BINARY LOG
            STATUS
       </code>
      </a>
      or
      <a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
       <span class="command">
        <strong>
         mysqldump
        </strong>
       </span>
      </a>
      <a class="link" href="mysqldump.html#option_mysqldump_source-data">
       <code class="option">
        --source-data
       </code>
      </a>
      are empty.
            In that case, the values that you need to use later when
            specifying the source's binary log file and position
            are the empty string (
      <code class="literal">
       ''
      </code>
      ) and
      <code class="literal">
       4
      </code>
      .
     </p>
    </li>
   </ol>
  </div>
  <p>
   You now have the information you need to enable the replica to
        start reading from the source's binary log in the correct
        place to start replication.
  </p>
  <p>
   The next step depends on whether you have existing data on the
        source. Choose one of the following options:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      If you have existing data that needs be to synchronized with
            the replica before you start replication, leave the client
            running so that the lock remains in place. This prevents any
            further changes being made, so that the data copied to the
            replica is in synchrony with the source. Proceed to
      <a class="xref" href="replication-snapshot-method.html" title="19.1.2.5 Choosing a Method for Data Snapshots">
       Section 19.1.2.5, “Choosing a Method for Data Snapshots”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      If you are setting up a new source and replica combination,
            you can exit the first session to release the read lock. 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>
      for how to
            proceed.
     </p>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
