Rechercher dans le manuel MySQL
17.1.2.4 Obtaining the Replication Master Binary Log Coordinates
To configure the slave to start the replication process at the correct point, you need to note the master's current coordinates within its binary log.
This procedure uses FLUSH TABLES WITH
READ LOCK
, which blocks
COMMIT
operations for
InnoDB
tables.
If you are planning to shut down the master 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 master creates a new binary log file on restart. The master binary log coordinates where the slave must start the replication process are therefore the start of that new file, which is the next binary log file on the master following after the files that are listed in the copied binary log index file.
To obtain the master binary log coordinates, follow these steps:
Start a session on the master by connecting to it with the command-line client, and flush all tables and block write statements by executing the
FLUSH TABLES WITH READ LOCK
statement:WarningLeave the client from which you issued the
FLUSH TABLES
statement running so that the read lock remains in effect. If you exit the client, the lock is released.In a different session on the master, use the
SHOW MASTER STATUS
statement to determine the current binary log file name and position:- +------------------+----------+--------------+------------------+
- +------------------+----------+--------------+------------------+
- +------------------+----------+--------------+------------------+
The
File
column shows the name of the log file and thePosition
column shows the position within the file. In this example, the binary log file ismysql-bin.000003
and the position is 73. Record these values. You need them later when you are setting up the slave. They represent the replication coordinates at which the slave should begin processing new updates from the master.If the master has been running previously with binary logging disabled, the log file name and position values displayed by
SHOW MASTER STATUS
or mysqldump --master-data will be empty. In that case, the values that you need to use later when specifying the slave's log file and position are the empty string (''
) and4
.
You now have the information you need to enable the slave to start reading from the binary log in the correct place to start replication.
The next step depends on whether you have existing data on the master. Choose one of the following options:
If you have existing data that needs be to synchronized with the slave 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 slave is in synchrony with the master. Proceed to Section 17.1.2.5, “Choosing a Method for Data Snapshots”.
If you are setting up a new master and slave replication group, you can exit the first session to release the read lock. See Section 17.1.2.6.1, “Setting Up Replication with New Master and Slaves” for how to proceed.
Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-replication-howto-masterstatus.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.