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 principle and precautions of MySQL master-slave replication

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

Share

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

This article mainly introduces the principle of MySQL master-slave replication and what matters needing attention, has a certain reference value, friends who need can refer to it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

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 the master-slave replication step 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.

Thank you for reading this article carefully. I hope the editor will share the principle of MySQL master-slave replication and what matters needing attention are helpful to everyone. At the same time, I also hope that you will support us, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you to learn!

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