To configure replication on the slave you must determine the master's current coordinates within its binary log. You will need this information so that when the slave starts the replication process, it is able to start processing events from the binary log at the correct point.
If you have existing data on your master that you want to synchronize on your slaves before starting the replication process, you must stop processing statements on the master, and then obtain its current binary log coordinates and dump its data, before allowing the master to continue executing statements. If you do not stop the execution of statements, the data dump and the master status information that you use will not match and you will end up with inconsistent or corrupted databases on the slaves.
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:
          
mysql> FLUSH TABLES WITH READ LOCK;
            For InnoDB tables, note that
            FLUSH TABLES WITH
            READ LOCK also blocks
            COMMIT operations.
          
              Leave 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:
          
mysql > SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000003 | 73       | test         | manual,mysql     |
+------------------+----------+--------------+------------------+
            The File column shows the name of the log
            file and Position shows the position
            within the file. In this example, the binary log file is
            mysql-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 without binary
            logging enabled, 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
            ('') and 4.
          
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.
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 and then proceed to Section 16.1.1.5, “Creating a Data Snapshot Using mysqldump”, or Section 16.1.1.6, “Creating a Data Snapshot Using Raw Data Files”. The idea here is to prevent any further changes so that the data copied to the slaves is in synchrony with the master.
If you are setting up a brand new master and slave replication group, you can exit the first session to release the read lock.


User Comments
Add your own comment.