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

The principle and function of MySQL Master-Slave replication

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article will explain in detail the principle and function of MySQL master-slave replication, the content of the article is of high quality, so share it for your reference. I hope you can get something after reading this article.

First, the database has a "bin-log" binary file that records all the SQL statements; then the SQL statement of the "bin-log" file of the master database is copied; finally, the copy SQL statement is executed in the "relay-log" redo log file of the database.

Master-slave replication

Master-slave replication is used to establish a database environment exactly the same as the master database, which is called the slave database. The master database is generally a quasi-real-time business database. Single item and asynchronous assignment are supported in the most commonly used mysql databases. During the assignment process, one server acts as the master server and the other server acts as the slave server; at this point the master server writes the update information to a specific binary file.

An index of the file is maintained to track log loops. This log can be recorded and sent to updates from the server. When a slave server connects to the master server, the slave server informs the master server to read the location of the last successful update from the server's log file. The slave server then receives any updates from which time it occurs, then locks it and waits for the master server to notify the new update.

The role of master-slave replication

1. Hot backup of data, as a backup database, after the failure of the master database server, you can switch to the slave database to continue to work to avoid data loss.

2. The extension of the architecture. Due to the increasing volume of business, the access frequency of Iamp O is too high to be satisfied by a single machine. At this time, the storage of multiple databases can be done to reduce the access frequency of disk Iamp O and improve the performance of single machine.

3. Read and write separation, so that the database can support greater concurrency. It is especially important in the report. As part of the report sql statement is very slow, resulting in table lock, affecting the front desk service. If the foreground uses master and the report uses slave, then the report sql will not cause the foreground lock and ensure the speed of the foreground.

After reading the above, do you have any further understanding of the principle and function of MySQL master-slave replication? If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading.

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: 0

*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