MySQL 5.6 master-slave replication Part 4 [some ignored Operation Details]

Source: Internet
Author: User

MySQL 5.6 master-slave replication Part 4 [some ignored Operation Details]

1. STOP SLAVE
 
There are two types of threads responsible for synchronization from the server:
1) IO thread
2) SQL thread
 
IO thread is responsible for obtaining binary logs on the master and executing Multiple SQL threads.
 
IO thread determines Retrieved_Gtid_Set
SQL thread determines Executed_Gtid_Set
 
Since IO thread is prior to SQL thread, Retrieved_Gtid_Set may be slightly more than Executed_Gtid_Set.
For example:

 


Mysql [localhost] {msandbox} (test)> SHOW slave STATUS \ G
.......
.......
Retrieved_Gtid_Set: 67cd9435-7cae-11e2-aa8d-00241db92e69: 1-9
Executed_Gtid_Set: 67cd9435-7cae-11e2-aa8d-00241db92e69: 1-7
Auto_Position: 1

Therefore, when stopping slave, the correct operation is:
1) stop slave io_thread;
2) show slave status: Make sure Executed_Gtid_Set has caught up with Retrieved_Gtid_Set.
3) stop slave SQL _thread.
 
2. flush tables with read lock and show slave status
 
Open a session 1 on a fully normal slave server:
Mysql> flush tables with read lock;
If the master server is updated,
Run another session2 on the server:
Mysql> show slave status will be stuck until the unlock tables is executed in session1.
 
If show slave status is also executed in session 1, it cannot be recovered ....
 
Mysql [localhost] {msandbox} (test)> flush tables with read lock;
Query OK, 0 rows affected (0.01 sec)
// The master server is updated.
Mysql [localhost] {msandbox} (test)> show slave status;
Stuck here...
Of course, ctrl + c can be canceled,
 
Ctrl-C-sending "kill query 1" to server...
Ctrl-C-query aborted.
Ctrl-C-sending "KILL 1" to server...
Ctrl-C-query aborted.
ERROR 2013 (HY000): Lost connection to MySQL server during query
Mysql [localhost] {msandbox} (test)>
It is useless even if you unlock tables .. The connection has been disconnected ..
Mysql [localhost] {msandbox} (test)> unlock tables;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 14
Current database: test
 
Query OK, 0 rows affected (0.01 sec)
 
And now mysqld cannot stop...
[Modify @ H209 msb_5_6_10_ B] $./stop
Warning; Aborted waiting on pid file: '/home/modify/sandboxes/msb_5_6_10_ B/data/mysql_sandbox5612.pid' after 190 seconds
Attempting normal termination-kill-15 10858
 
So before flush tables with read lock, stop slave...
 
Http://bugs.mysql.com /? Id = 68460

MySQL 5.6 master-slave replication Part 1 [Introduction and configuration]

MySQL 5.6 master-slave replication Part 2 [restore an slave server]

MySQL 5.6 master-slave replication Part 3 [upgrade slave server to master server]

MySQL 5.6 master-slave replication Part 4 [some ignored Operation Details]

MySQL master-slave Replication Event validation MySQL Replication Event Checksum

Use pt-table-checksum to check whether master-slave replication is normal

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.