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

Write down an error in MySQL master-slave replication

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

Share

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

This master-slave copy often errors, I am ***, the last time the reason is that there is a problem with the configuration file of the slave library, I have solved it, and today there is an error, as shown in the figure: So the solution is to skip the wrong transaction.

Prior to MySQL 5.6, it was only necessary to execute:

mysql>set global sql_slave_skip_counter=1;

Skipping a wrong transaction allows replication to continue, but not after MySQL 5.6:

Analysis:

Because it is copied through gtid, it needs to skip this transaction to continue copying. This transaction can be viewed in the binlog of the master: because I don't know which GTID is wrong, I don't know how to skip which GTID. But in the information in show slave status, you can find POS:635508 in Executive Master.

from the command

mysql> SHOW BINLOG EVENTS in 'mysql-bin.002121' from 635508 limit 10;

You can view the GTID to be adjusted.

mysql-bin.002121 | 635508 | Gtid | 1408099586 | 635573 | SET @@SESSION.GTID_NEXT= '9b4f9d6b-5777-11e8-9e63-ec0d9a2fab3e:97831165'

Then, execute as follows:

mysql>set session gtid_next= '9b4f9d6b-5777-11e8-9e63-ec0d9a2fab3e:97831165';

mysql>begin;

mysql>commit;

mysql>SET SESSION GTID_NEXT = AUTOMATIC;

mysql>start slave;

Then check the status

Problem solved,Perfect!

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