mysql 复制 Seconds Behind Master: 11588

赞赏 2017-05-25


1、故障说明,昨晚在线执行一条修改字段的sql,涉及数据行850346,执行过程花了将近1分钟

2、执行完成后,发现从库报警了,从nagios上查看报警信息

     SLOW_SLAVE CRITICAL: Slave IO: Yes Slave SQL: Yes Seconds Behind Master: 11588

3、百度后发现是是从库sql线程假死(双主模式,当前问题均是从库上),查看mysql进程信息


4、出现琐表的情况,当时处理是是kill掉进程,然后stop slave 重做change master ,最后start slave 。操作完成后slave 恢复正常

5、但是上述操作并没有解决根本问题,slave上出现了丢数据的情况,因为主从假死比较久,数据又比较多,丢了多少数据还不得知

6、这里就需要percona工具包来检验数据的一致性了。pt-table-checksum 来检测

      检测过程中碰到麻烦,

      pt-table-checksum  --nocheck-plan --nocheck-replication-filters --nocheck-binlog-format --create-replicate-table  --databases=xxx --replicate=test.checksums --create-replicate-table  --host=192.168.1.237  --port 3306  -uxxx_slave -p'slave_xxx'


     出现报错:

      04-28T11:31:41 Failed to /*!50108 SET @@binlog_format := 'STATEMENT'*/: DBD::mysql::db do failed: Access denied; you need 

(at least one of) the SUPER privilege(s) for this operation [for Statement "/*!50108 SET @@binlog_format := 'STATEMENT'*/"] 

at /usr/bin/pt-table-checksum line 9028.

This tool requires binlog_format=STATEMENT, but the current binlog_format is set to MIXED and an error occurred while attempting to change it.  

If running MySQL 5.1.29 or newer, setting binlog_format requires the SUPER privilege.  You will need to manually set binlog_format to 'STATEMENT' before running this tool.

     这个需要更改binlog的记录模式,因为我们线上的binlog记录是采用statment(基于sql的记录),

     需要改成混合模式才能执行检测

7、检测完成后需要用pt-table-sync来修复不一致的数据。

    pt-table-sync --print --replicate test.checksums --sync-to-master h=192.168.1.237,P=3306,u=xxx_slave,p=slave_xxx

8、总结,如果是5,6以后的版本,建议采用基于gtid的主从复制模式,维护起来比较简单


登陆后阅读全文
阅读 1532 赞赏 0 有用 0 没用 0 收藏 0 分享

   


作者声明:本篇文章系本人原创,欢迎分享,但未经许可,谢绝转载。

0 条留言

Ω的头像

Ω

他的文章

mysql5.7安装

mysql 复制 Seconds Behind Master: 11588

手机扫一扫
分享文章