MySQL master-slave replication error and Solution

Source: Internet
Author: User

Error Code 1 in the slave log:

  1. [ERROR] Error reading packetFromServer: Client requested masterToStart replicationFromImpossible position;LastEvent wasRead From 'Mysql-bin.20.16' At455562731,LastByteReadWasRead From 'Mysql-bin.20.16' At4. (server_errno = 1236)
  2. 120725 23:19:17 [ERROR] Slave I/O: Got fatal error 1236FromMasterWhenReading dataFrom BinaryLog:'Client requested master to start replication from impossible position; the last event was read from'Mysql-bin.000016'At 100'Error_code: 1236

Solution:

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

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

Check whether there are rows corresponding to 455562 or rows that are very similar to this number, and then use the chang master to command to skip this line. The command format is as follows:

 
 
  1. stop slave;  
  2. 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;  
  3. start slave;  

If you cannot find 455562 or a line that is very close to this number, you can use the following command to view'Mysql-bin.000016 rows

 
 
  1. ls -la mysql-bin.000016  

If the number of rows is much less than 455562, you can skip this log and copy it from the next log. The command is as follows:

 
 
  1. stop slave;  
  2. 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;  
  3. start slave;  

Error Type Code 2:

Mysql slave Error_code: 1062 1054

If such code appears in the log, it may be the wrong select or update operation. The master skips these operations but is recorded in the binary log, slave will perform the same action based on the statements in the binary, and an error will be reported. It is easy to understand the principle and perform the operation.

 
 
  1. Stop slave;
  2. Set gloableSQL _slave_skip_counter= N; // n the number of statements you want to skip
  3. Start slave;

If you do not want to encounter such an error, you can write it to the slave configuration file in the following format:

 
 
  1. Slave_skip_errors=1062 
  2. Slave_skip_errors=All// Skip all types of error codes

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.