首页 > 数据库技术 > 详细

MYSQL主从库不同步故障一例解决方法

时间:2016-01-16 08:59:26      阅读:273      评论:0      收藏:0      [点我收藏+]
于是:

1、在主库中创建一个临时库,将需要导入的表文件复制过来

2、执行

create database tmpdb;

create table tmptable;

cp mysql_date_file master_data_file //shell command 复制数据表文件到master data_dir下

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

执行完后,主库中数据导入正常

再看slave status

show slave status;

发现错误:not found tmpdb.tmptable (大致意思是这个,原来的错误信息没有记录下来)

匆忙中,看show master status 中Master_Log_Pos 标记为$Master_Log_Pos

然后在slave 上 CHANGE MASTER TO MASTER_LOG_POS=$Master_Log_Pos

然后再看show master status,发现有1162错误

到现在发现两边的数据不能同步了

。。。。。。

冥思苦想,不会重新做一遍主从库吧?

mysqlbinlog 我突然想到了它

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

找到了在slave上执行错误的SQL

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

vi /tmp/tmpbinlog (find tmptable)

找到错误SQL的下一个# at (一串数字)标记为$NEXT_POS

在slave 上 CHANGE MASTER TO MASTER_LOG_POS=$NEXT_POS

show slave status 显示:

Slave_IO_Running: Yes
Slave_SQL_Running: Yes

哈哈,完成同步。

如果中间碰到1062错误 在slave配置文件中设定slave-skip-errors=1062,重启slave

MYSQL主从库不同步故障一例解决方法

原文:http://www.jb51.net/article/23844.htm

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!