Mysql:How do I force the master to block updates until the slave catches up?

A.14.4.

How do I force the master to block updates until the slave catches up?

 

Use the following procedure:

  1. On the master, execute these statements:

    mysql> FLUSH TABLES WITH READ LOCK;
    mysql> SHOW MASTER STATUS;
    

    Record the replication coordinates (the current binary log file name and position) from the output of the SHOW statement.

  2. On the slave, issue the following statement, where the arguments to the MASTER_POS_WAIT() function are the replication coordinate values obtained in the previous step:

    mysql> SELECT MASTER_POS_WAIT('log_name', log_pos);
    

    The SELECT statement blocks until the slave reaches the specified log file and position. At that point, the slave is in synchrony with the master and the statement returns.

  3. On the master, issue the following statement to enable the master to begin processing updates again:

    mysql> UNLOCK TABLES;
    

猜你喜欢

转载自www.cnblogs.com/jinzhenshui/p/12566153.html