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

很文博客hinven.com 数据库评论395字数 969阅读模式
广告也精彩

第一次做完主从库同步后正常,但工作过程中发现有一个库的数据库没有同步起来,在另外一个mysql(3307)中
于是:

1、在主库中创建一个临时库,将需要导入的表文件复制过来文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/44920.html

2、执行文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/44920.html

create database tmpdb;文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/44920.html

create table tmptable;文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/44920.html

cp mysql_date_file master_data_file //shell command 复制数据表文件到master data_dir下文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/44920.html

insert into master.tmptable select * from tmpdb.tmptable;文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/44920.html

执行完后,主库中数据导入正常文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/44920.html

再看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

工具:作品在线观看

女优:最新作品观看

中文:国语在线观看

weinxin
我的微信
扫一扫更精彩
大家的支持是我更新的动力!!!
 
广告也精彩
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证