MYSQL Master/Slave database non-synchronization fault case solution

Source: Internet
Author: User
After the master-slave Database Synchronization is completed for the first time, it is normal, but the database of one database is not synchronized during the working process. In another mysql (3307 ),

After the master-slave Database Synchronization is completed for the first time, it is normal, but the database of one database is not synchronized during the working process. In another mysql (3307 ),

So:

1. Create a temporary database in the master database and copy the table files to be imported.

2. Execute

Create database tmpdb;

Create table tmptable;

Cp mysql_date_file master_data_file // shell command copies the data table file to the master data_dir

Insert into master. tmptable select * from tmpdb. tmptable;

After execution, the data in the master database is imported normally.

Check the slave status again.

Show slave status;

Error found: not found tmpdb. tmptable (this indicates that the original error message is not recorded)

In a hurry, check that Master_Log_Pos in show master status is marked as $ Master_Log_Pos.

Then on slave, change master to MASTER_LOG_POS = $ Master_Log_Pos

Then let's look at the show master status and find 1162 errors.

The data on both sides cannot be synchronized.

......

Do you want to retry the master-slave database?

Mysqlbinlog I suddenly thought of it

So mysqlbinlog -- start-position = 190000000 -- stop-position = 200000000 xxx. binlog | grep tmptable

Locate the SQL statement that is incorrectly executed on slave

Mysqlbinlog -- start-position = 190000000 -- stop-position = 200000000 xxx. binlog | grep tmptable>/tmp/tmpbinlog

Vi/tmp/tmpbinlog (find tmptable)

Locate the next # at (a string of numbers) in the wrong SQL statement and mark it as $ NEXT_POS.

On slave, change master to MASTER_LOG_POS = $ NEXT_POS

Show slave status display:

Slave_IO_Running: Yes
Slave_ SQL _Running: Yes

Haha, complete synchronization.

If a 1062 error occurs, set slave-skip-errors = 1062 in the slave configuration file, and restart slave.

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.