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

What is the underlying principle of MySQL master-slave replication?

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

Share

Shulou(Shulou.com)05/31 Report--

This article introduces you what is the underlying principle of MySQL master-slave replication, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Principle of master-slave replication

(1) Master records data changes to the binary log (binary log), that is, the file specified by the configuration file log-bin. These records are called binary log events (binary log events).

(2) Slave reads the binary log events in Master and writes it to its relay log (relay log) through the Ibind O thread.

(3) Slave redoes the events in the relay log, executing the event information in the relay log one by one locally, and completing the local storage of the data, thus realizing the change reflected in its own data (data playback).

Matters needing attention

(1) the version and number of digits of the master-slave server operating system are the same.

(2) the versions of Master and Slave databases should be the same.

(3) the data in Master and Slave databases should be consistent.

(4) Master enables binary logs, and the server_id of Master and Slave must be unique in the LAN.

Configure master-slave replication steps

Master database

(1) install the database

(2) modify the database configuration file, specify server_id, and enable binary log (log-bin)

(3) start the database to check which log is currently and what is the position number

(4) Log in to the database and authorize the user to copy the data (the IP address is the slave IP address. If it is a two-way master-slave, you also need to authorize the local IP address. In this case, your IP address is the slave IP address)

(5) back up the database (remember to lock and unlock)

(6) transfer backup data to Slave

(7) start the database

The above steps are required to successfully build an one-way master / slave and to build a two-way master / slave:

(1) Log in to the database and specify the address, user, password and other information of the Master (this step is only required for two-way master / slave)

(2) enable synchronization and view status

Configuration on Slave

(1) install the database

(2) modify the database configuration file to specify server_id (if you are building a two-way master / slave, you should also enable binary log log-bin)

(3) start the database and restore the backup

(4) check which log is currently and what the position number is (this step is not required for one-way master-slave, but for two-way master-slave)

(5) specify the address, user, password and other information of Master

(6) enable synchronization and check the status.

What is the underlying principle of MySQL master-slave replication is shared 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.

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

Wechat

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

12
Report