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 1236 error in the mysql database cluster causes the master database and slave database to fail to synchronize.

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

Share

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

The sync_binlog parameter in / etc/my.cnf sets the number of transactions accumulated before dropping the disk.

Description:

1. Saving data to the database and setting down the binlog disk are carried out at the same time.

two。 The data is stored in memory first, and the set number of transactions is reached before the disk is dropped.

3. The data read from the library is the data in the memory of the main library, not the data from the disk.

4. When writing data, as long as the main library is alive, it is written to the main library.

Process status record:

Premise: 50 transactions as soon as they are closed

1. Before power off: the memory of the main library is going from 50 to 60, read from the memory of the main library to 58 and store it in the slave library

two。 Power outage: 50-60% of the data in the main library exists in memory, binlog cannot be removed, and the data is not saved to the database file. Start writing data to slave library, data to 61, and then data is gradually written to slave library

3. Restart of the main library: 50-60 binlog on the main library is lost, data is lost, data is written to the main library, and the binlog record starts at 50. When the slave library reads the data from the main memory to 50, when the slave library finds that it has received 50% of the data, it will no longer receive it and will not synchronize it. At this time, the status is: only write data to the master library, and the slave library is out of sync.

4. The final result: the data from the database is 1-58. 61 -. What is missing is 58-60, and the data in the main database is 1-49. -...

Complete process description:

After 50 transactions, the master database is writing data. When the power is cut off, the memory of the master database is written to 60, and the slave database reads to 58 from the memory of the master database. After reading from the database to 58, the data is generated to the slave database. Due to less than 50 transactions, the master database will not save the disk. As a result, transactions between 50 and 60 failed to generate binlog logs to the disk, and the data was not written to the database file, resulting in the loss of 58-60 data on neither the master database nor the slave database. After the master library is restarted, since the data recorded on the disk is 49, it is recorded from 50. When the slave library reads from the master database, it is found that it already has 50, so there is a conflict and the data of the master database cannot be read any more.

Phenomenon: synchronization is damaged, after the main database is restarted, the data is written again, only to the main database.

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