mysql复制出错又一例

来源:网络 责任编辑:栏目编辑 发表时间:2013-07-01 21:58 点击:

今天mysql复制又出错了,同事在用navicat操作主数据库,引起不同步.
1. show slave stauts\G
            Master_Log_File: mysql-bin.000027
        Read_Master_Log_Pos: 604734247
             Relay_Log_File: mysqld-relay-bin.000002
              Relay_Log_Pos: 85998
      Relay_Master_Log_File: mysql-bin.000027
           Slave_IO_Running: Yes
          Slave_SQL_Running: No
            Replicate_Do_DB:
        Replicate_Ignore_DB:
         Replicate_Do_Table:
     Replicate_Ignore_Table:
    Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
                 Last_Errno: 0
                 Last_Error: Could not parse relay log event entry. The possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's MySQL code. If you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave.
               Skip_Counter: 0
        Exec_Master_Log_Pos: 588269801
            Relay_Log_Space: 16550444
 
根据提示检查到底是主binary log还是relay log 出错.
   1. 检查主binary log
mysqlbinlog --no-defaults  --start-position=588269801  mysql-bin.000027 > master.sql
   2.检查从relay log
mysqlbinlog --no-defaults  --start-position=85998    mysqld-relay-bin.000002 > slave.sql
如果两个log中有错误的话,上面命令是执行不成功的必须加上 –f 参数.
然后在master.sql中找到如下命令,其中Unknown event就是不能被识别执行的命令,relay_log就卡在这里了.
# at 588269801
#110816 14:45:50 server id 1  end_log_pos 588269874     Query   thread_id=7249444       exec_time=0     error_code=0
SET TIMESTAMP=1313477150/*!*/;
BEGIN
/*!*/;
# at 588269874
#110816 14:45:50 server id 1  end_log_pos 588269941
# Unknown event
# at 588269941
#110816 14:45:50 server id 1  end_log_pos 588270071
# Unknown event
# at 588270071
#110816 14:45:50 server id 1  end_log_pos 588270145     Query   thread_id=7249444       exec_time=0     error_code=0
SET TIMESTAMP=1313477150/*!*/;
COMMIT
知道了原因就好办了,直接跳过即可.
1. stop slave;
2. change master to master_host='192.168.1.13', master_user='slave', master_password='slavepasswd', MASTER_LOG_FILE='mysql-bin.000027', MASTER_LOG_POS=588270071;
3. start slave;
当然如果有多个这样的Unknown event事件,这样做就很麻烦了.
可以先把master.sql 在slave上执行,然后找到文件最后一个的postion的值, 重新设置change master 也是可行的.
 
不知道SET GLOBAL SQL_SLAVE_SKIP_COUNTER = N;会不会对这种情

    相关新闻>>

      发表评论
      请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
      用户名: 验证码:点击我更换图片
      最新评论 更多>>

      推荐热点

      • mysql-mmm
      • mysqldump命令——MySQL数据库备份还原
      • Oracle数据导入MySQL的快捷工具:MySQL Migration Toolkit
      • 简简单单储存过程——循环一个select结果集
      • MySQL数据库十大优化技巧
      • Mysql主主复制架构配置
      • Mysql安装笔记
      • MySQL Stmt预处理提高效率问题的小研究
      • Mysql的Procedure 参数为NULL问题分析
      网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
      Copyright © 2008-2015 计算机技术学习交流网. 版权所有

      豫ICP备11007008号-1