Get the App
SLTechnology News&Howtos  ›  Database  › 

What is the detailed process of MySQL master-slave replication?

Shulou Source: shulou.com Published: 2022-05-31 14:04:48 10月03日 Update

This article will explain in detail the detailed process of MySQL master-slave replication, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

MySQL database replication operation can be roughly divided into three steps, as shown in the following figure:

1. The primary server records changes or updates to the data in the binary log.

two。 The slave server copies the binlog events of the master server to its own relay log (relay log).

3. The SQL thread from the server reads the contents of the relay-log log, performs the various operations recorded in the log in full sequence, and applies them to the slave server.

The detailed process of master-slave synchronization is as follows:

The primary server verifies the connection.

The master server starts a thread for the slave server.

The slave server tells the master server the offset of the master server log.

The primary server checks whether the value is less than the current binary log offset.

If less than, the notification fetches the data from the server.

The slave server continues to fetch data from the master server until it is finished, when the slave server thread goes to sleep, and the master server thread goes to sleep at the same time.

When there is an update on the master server, the master server thread is activated, the binary log is pushed to the slave server, and the slave server thread is notified to enter the working state.

The binary log is executed from the server SQL thread and then goes to sleep.

On the MySQL master-slave replication process is how to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Server service log thread binary data master-slave process content sleep article more status knowledge article offset update yes three below Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Information Linux Redmi Apple