---
title: "mysql主从同步因断电产生的不能同步问题"
author: "wayne173"
date: "2013-06-26T09:03:33Z"
tags: []
categories: ["数据库"]
slug: "mysql"
draft: false
lastmod: "2013-06-26T09:03:33Z"
id: 1894480
url: "https://wayne173.iteye.com/blog/1894480"
---

偶尔因为断电导致mysql slave 出现复制错误“Could not parse relay log event entry”

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.

 

先查询下状态

show slave status \\G

 

Master\_Host: 192.168.2.51

                Master\_User: backupuser

                Master\_Port: 3306

              Connect\_Retry: 60

            Master\_Log\_File: mysql-bin.000078

        Read\_Master\_Log\_Pos: 984673998

             Relay\_Log\_File: memcached-relay-bin.000039

              Relay\_Log\_Pos: 747157846

      Relay\_Master\_Log\_File: mysql-bin.000078

           Slave\_IO\_Running: Yes

          Slave\_SQL\_Running: No

 

          Skip\_Counter: 0

        Exec\_Master\_Log\_Pos: 747157709

            Relay\_Log\_Space: 984679197

 

如果可以确定主服务器没有问题的话，那么重置下从服务器的同步位置就可以了。

如上可以对应的指令为：

stop slave;

CHANGE MASTER TO  MASTER\_LOG\_FILE = 'mysql-bin.000078', MASTER\_LOG\_POS =747157709;

start slave;

再用 show slave status \\G 查看状态。如下：

Master\_Log\_File: mysql-bin.000078

        Read\_Master\_Log\_Pos: 879029246

             Relay\_Log\_File: memcached-relay-bin.000002

              Relay\_Log\_Pos: 1336369

      Relay\_Master\_Log\_File: mysql-bin.000078

           Slave\_IO\_Running: Yes

          Slave\_SQL\_Running: Yes

            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: 

               Skip\_Counter: 0

        Exec\_Master\_Log\_Pos: 748493843

            Relay\_Log\_Space: 131871772

            Until\_Condition: None

             Until\_Log\_File: 

              Until\_Log\_Pos: 0

         Master\_SSL\_Allowed: No

         Master\_SSL\_CA\_File: 

         Master\_SSL\_CA\_Path: 

            Master\_SSL\_Cert: 

          Master\_SSL\_Cipher: 

             Master\_SSL\_Key: 

      Seconds\_Behind\_Master: 339469

 

好了到现在搞定了。

还有说法是内存不够用产生的，有人清除了几个不用的进程释放内存后， stop slave; start slave；然后好了，我遇到的不是这个情况，如果你遇到了，按我上面的不能解决的话，可以试着释放内存看看。