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

How to solve the problem of MYSQL master inconsistency

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

Share

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

This article introduces how to solve MYSQL master-slave inconsistency, the content is very detailed, interested friends can refer to it, I hope it can help you.

Master-slave inconsistency in MYSQL is very likely to occur, and how to find inconsistency is not a very simple problem. Especially when the data volume is large. It is useless to talk nonsense. Look at the following example:

Let's start by creating a stored procedure to insert our initialization data

delimiter //

DROP PROCEDURE IF EXISTS insert_test_val;

##num_limit Number of data to insert,rand_limit Maximum random number

CREATE PROCEDURE insert_test_val()

BEGIN

DECLARE i int default 1;

DECLARE a varchar(20) ;

DECLARE b smallint ;

DECLARE c smallint ;

WHILE i /data/fix.sql

Import SQL after export in the associated library

Then go back to the main library, clean up the checksums table, and then execute the command again. Looking at the chekcsums table, you can clearly see that the values of each chunk are equal.

You can see that data that fixes differences is OK.

Just now, the data is different (missing data). If the data inside is not missing, just the value inside changes, will it be impossible to use this tool? The answer is impossible.

We can try changing the name value from the library

In the screenshot we changed the NAME value

We can clearly see from the command just now that the relevant modified records can be found and repaired.

So far, the PT tool to fix the master-slave inconsistency method is still very effective, but if most of your tables are inconsistent, it is recommended to do a master-slave copy more efficient.

MYSQL also provides a checksum table command that can quickly determine whether one table is different from another. Note that the use here is not the same, through the official text prompt two different tables is also possible to produce consistent values, of course, such a probability will be relatively low.

How to solve MYSQL master-slave inconsistency is shared here. I hope the above content can be of some help to everyone and learn more knowledge. If you think the article is good, you can share it so that more people can see it.

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

Internet Technology

Wechat

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

12
Report