zoukankan      html  css  js  c++  java
  • mysql主从不同步问题 Error_code: 1032

    1、通过命令查看从库状态mysql> show slave status G

    发现错误

    Could not execute Update_rows event on table mysql.user; Can't find record in 'user', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.002339, end_log_pos 1465

    错误描述比较明显,在更新 mysql.user表的行时无法更新,缺少更新的记录。

    2、去主库找 log mysql-bin.002339  end_log_pos 1465这个点,发现由于时间过长,主库的binlog已经自动清除掉了 (由expire_logs_days参数控制)

    3、在从库找到relaylog执行到的点

    Relay_Log_File: mysqld-relay-bin.007023
                    Relay_Log_Pos: 283

    通过mysqlbinlog查看这个点的SQL。

    在使用mysqlbinlog是碰到一个问题

    ERROR: Error in Log_event::read_log_event(): 'Sanity check failed', data_len: 41, event_type: 30 

    ERROR: Could not read entry at offset 1331: Error in log format or read error.

    检查版本,发现binlog版本不对,mysql5.6对应的应该是mysqlbinlog 3.4 故应该用3.4版本进行对relaylog的解析

    #mysqlbinlog --version

    mysqlbinlog Ver 3.3 for redhat-linux-gnu at x86_64

    #/data/server/mysql-5.6.24/bin/mysqlbinlog --version

    /data/server/mysql-5.6.24/bin/mysqlbinlog Ver 3.4 for linux-glibc2.5 at x86_64 

    mysql> select @@version;
    +-------------------------------------------+
    | @@version                                 |
    +-------------------------------------------+
    | 5.6.24-enterprise-commercial-advanced-log |
    +-------------------------------------------+
    1 row in set (0.00 sec)
    4、最后在relaylog找到 Relay_Log_Pos: 283这个点,发现SQL在对用户进行修改,但从库root用户的host与主库不相符,把从库root用户的host改成与主库一致后,主从就同步了。
  • 相关阅读:
    ASP.NET MVC 入门9、Action Filter 与 内置的Filter实现(介绍) 【转】
    一个建议,看看大家的意见。
    发现不错的文章,推!
    有个小问题,大家一起研究。
    逼不得已,这个我确实不会,昨办?
    MSN Message6.2 的小BUG
    在IE7浏览器中切换成以资源管理器方式
    手机罗盘(指南针)校准方法
    G13/ Wildfire S/A510e link2SD教程,干净清洁的安装程序到内存卡
    HTC G13电池怎么鉴别真伪
  • 原文地址:https://www.cnblogs.com/Knight7971/p/9915757.html
Copyright © 2011-2022 走看看