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

Building Master-Slave replication of MySQL under Linux (1)

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

Share

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

The construction of one-slave-one-master mode

1. Principle of master-slave replication

1. The slave server uses IO Thread to send a request to the master server. After the master server receives the request, it responds the binary log file to the IO Thread of the slave server through the dump Thread thread. 3. The received information from the server is written to the relay log through IO Thread, and the event and time of the received log file are recorded at the same time. 4. The log is then relayed from the server's SQL Thread readings and converted to SQL statements and executed, saving the data to disk while writing to the slave server's binary log file.

two。 The mode and preparation of master-slave service

Mode: synchronization: the master server sends the binary file to the cluster server. After the cluster server saves successfully, the cluster server returns a message to the master server, and the master server returns the message to the client. Async: after the master server has finished writing, the message is returned directly to the client. Preliminary preparation: 1. The mysql version of the master-slave server should be consistent, and the inconsistent master version should be lower than the slave version. two。 The master-slave server starts from scratch, that is, the two databases are the insertion of no data in the new database. 3. The master server runs for a period of time, backs up the master server, and then restores it on the slave server. Copy from where it was at the time of the backup. 12345671234567

3. Master server configuration

a. Change the Service ID of the primary server and open the binary log file

b. Create an account with replication permission

4. Configure from the server

a. Configure server_id and Relay Log

b. Link to the primary server

c. Start the replication thread

Test result

a. Master server add data

b. Server View

Double main mode 1. Both servers open binary log 2. Both servers turn on relay logs. The server id of the two servers must be different. The automatic growth factor and initial value of the two servers are not the same. Create SQL users with replication privileges on both servers

Result

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