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

Error and solution in mysql Master-Slave replication

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "error and solutions in mysql master-slave replication". In daily operation, I believe many people have doubts about error and solutions in mysql master-slave replication. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "error and solutions in mysql master-slave replication". Next, please follow the editor to study!

Error and solution in Master-Slave replication

Error code 1 in the slave log:

[ERROR] Error reading packet from server: Client requested master to start replication from impossible position; the last event was read from 'mysql-bin.000016' at 455562731, the last byte read was read from' mysql-bin.000016' at 4. (server_errno=1236)

120725 23:19:17 [ERROR] Slave Iamp O: Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replication from impossible position; the last event was read from' mysql-bin.000016' at 455562, Error_code: 1236

Rescue method: www.2cto.com

First check whether the corresponding log file in the main server has this line, the command used is

Mysqlbinlog / YOURPATH/'mysql-bin.000016 > > / test

Find out if there is a line corresponding to 455562 or a line that is very close to this number, and then use the chang master to command to skip the line. The command format is as follows

Stop slave

CHANGE MASTER TO MASTER_HOST='192.168.192.45',MASTER_USER='XXXX',MASTER_PASSWORD='XXXX',MASTER_LOG_FILE='mysql-bin.000016',MASTER_LOG_POS=455678

Start slave

If you can't find 455562 or a line close to this number, you can check the number of lines of 'mysql-bin.000016' with the following command

Ls-la mysql-bin.000016

If the number of rows counted is far less than 455562, you can skip this log and start copying from the next log, with the following command

Stop slave

CHANGE MASTER TO MASTER_HOST='192.168.192.45',MASTER_USER='backup',MASTER_PASSWORD='weiphone',MASTER_LOG_FILE='mysql-bin.000017',MASTER_LOG_POS=4

Start slave; www.2cto.com

Error type code 2:

Mysql slave Error_code: 1062 1054

If such a code appears in the log, it may be the wrong select, or update operation. Master skips these operations, but is recorded in the binary log. If slave does the same action according to the statements in the binary, it will report an error. Knowing the principle, the operation to be done is very simple.

Stop slave

Set gloable sql_slave_skip_counter=n; / / n is the number of error statements you want to skip

Start slave

If you don't want to encounter this kind of error again, you can write it to the slave configuration file in the following format:

Slave_skip_errors = 1062

Slave_skip_errors = all / / skip all types of error codes

At this point, the study of "error and solutions in mysql master-slave replication" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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: 212

*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

Wechat

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

12
Report