Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

That's why! Why can we continue the master-slave replication relationship after performing stop slave and then start slave?

2025-01-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Write it on the front:

We all know that Master is full of a binlog, or Master manually executes flush logs. SLave can continue to receive data from Master for synchronization without doing anything. I don't know if my friends have considered it. Why is this?

The reason is:

In fact, executing stop slave means closing the I/O thread (stop slave IO_THREAD) and SQL thread (stop slave SQL_THREAD) respectively. The I/O thread will maintain the update of master.info information, and the SQL thread will maintain the update of relay-log.info information. When executing start slave, I/O thread and SQL thread will continue to execute according to master.info and relay-log.info information, so replication can continue.

Here's a demonstration:

Execute on Master host:

mysql> show master status\G;

*************************** 1. row ***************************

File: mysql-bin.000008

Position: 120

Executed on Slave host

cat /home/data/mysql3306/master.info

mysql-bin.000008

120

192.168.32.3

Now manually scroll through the binlog log once in Master

mysql> flush logs;

mysql> show master status\G;

*************************** 1. row ***************************

File: mysql-bin.000009

Position: 120

Executed on Slave host

cat /home/data/mysql3306/master.info

23

mysql-bin.000009

120

192.168.32.3

As you can see, the Slave host copies Master's data exactly according to the master.info file.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 300

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report