1. What is MySQL master-slave synchronization? When the data in the master database changes, the changes will be synchronized to the slave database in real time. 2. What are the benefits of master-slave synchronization?
3. What is the principle of master-slave synchronization? First, let's understand the master-slave architecture. As shown below: Whether it is delete, update, insert, or creating functions and stored procedures, all operations are performed on the master. When the master has operations, the slave will quickly receive these operations and synchronize them. But how is this mechanism implemented? On the master machine, master-slave synchronization events are written to a special log file (binary-log); on the slave machine, the slave reads the master-slave synchronization events and makes corresponding changes on the slave library based on the changes in the read events. In this way, master-slave synchronization is achieved! Let’s take a closer look below. 3.1 What are the master-slave synchronization events? It is mentioned above: On the master machine, master-slave synchronization events will be written to a special log file (binary-log); There are three forms of master-slave synchronization events: statement, row, and mixed.
3.2 Operations on the master machine When the data on the master changes, the event (insert, update, delete) changes will be written to the binlog in sequence. binlog dump thread When the slave connects to the master, the master machine will start the binlog dump thread for the slave. When the master's binlog changes, the binlog dump thread will notify the slave and send the corresponding binlog content to the slave. 3.3 Operations on the slave machine When master-slave synchronization is turned on, two threads will be created on the slave.
3.4 How to view the above threads on the master and slave? You can view it using the SHOW PROCESSLIST command. As shown in the figure, view the binlog dump thread on the master machine. As shown in the figure, check the I/O and SQL threads on the slave machine. 4. Having said so much, let me summarize it with a picture 5. About actual combat For actual combat, please refer to my other article: MySQL master-slave synchronization actual combat The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: JavaScript code to implement Weibo batch unfollow function
>>: Vant+postcss-pxtorem implements browser adaptation function
In many cases, in order to beautify the form, the ...
Overview of MySQL MySQL is a relational database ...
Preface This article mainly introduces the releva...
Introduction to sudo authority delegation su swit...
All prerequisites require root permissions 1. End...
Table of contents Introduction to NFS Service Wha...
This article describes how to build a phalcon env...
One of our web projects has seen an increase in t...
Table of contents Implementing a search engine ba...
1. flex-grow, flex-shrink, flex-basis properties ...
Zabbix automatically discovers rules to monitor s...
Because I wrote a Python program and intensively ...
Overview Operations on any one database are autom...
Table of contents Linux environment variables and...
Table of contents ESLint plugin installation in H...