数据库

MySQL主从报错解决:Failed to initialize the master info structure

Jager · 3月29日 · 2016年 · · · 2399次已读

大清早收到一个MySQL的自定义语言告警 :replication interrupt,看来是主从同步报错了。
登陆MySQL,执行 show slave status \G 发现salve已经停止了,于是使用 start slave启动,结果有如下报错:
ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log

搜索了下,网上给出的解决办法基本都是:

①、执行 reset slave;

②、重新执行 change master:

mysql> change master to 
    -> master_host='192.168.1.100',
    -> master_port=3306,
    -> master_user='repl',
    -> master_password='repl',
    -> master_log_file='mysql-bin.000051',
    -> master_log_pos=254105;

③、执行 start slave

于是试了下,发现还是一样的报错,顺着报错信息,看了下error 日志:

160324  6:40:10 [ERROR] log *** glibc detected *** /data/mysql/bin/mysqld: corrupted double-linked list: 0x00002ab038100ab0 *** listed in the index, but failed to stat
160324  6:40:10 [ERROR] Error counting relay log space
160324  6:40:10 [ERROR] Failed to initialize the master info structure
160324  6:40:10 [Note] Event Scheduler: Loaded 0 events
160324  6:40:10 [Note] /data/mysql/bin/mysqld: ready for connections.
Version: '5.5.13-log'  socket: '/data/mysql/data/mysqld.sock'  port: 3306  Source distribution
160324  9:33:41 [ERROR] log *** glibc detected *** /data/mysql/bin/mysqld: corrupted double-linked list: 0x00002ab038100ab0 *** listed in the index, but failed to stat
160324  9:33:41 [ERROR] Error counting relay log space
160324  9:33:54 [ERROR] log *** glibc detected *** /data/mysql/bin/mysqld: corrupted double-linked list: 0x00002ab038100ab0 *** listed in the index, but failed to stat
160324  9:33:54 [ERROR] Error counting relay log space
160324  9:35:29 [ERROR] log *** glibc detected *** /data/mysql/bin/mysqld: corrupted double-linked list: 0x00002ab038100ab0 *** listed in the index, but failed to stat
160324  9:35:29 [ERROR] Error counting relay log space
160324  9:37:47 [ERROR] log *** glibc detected *** /data/mysql/bin/mysqld: corrupted double-linked list: 0x00002ab038100ab0 *** listed in the index, but failed to stat
160324  9:37:47 [ERROR] Error counting relay log space

发现其中频繁出现如下错误:

ist: 0x00002ab038100ab0 *** listed in the index, but failed to stat

于是,把MySQL 数据文件目录下的 index info 文件都看了一遍,结果发现 Centos64-relay-bin.index文件中出现异常内容:MySQL主从报错解决:Failed to initialize the master info structure

这个文件正常情况应该是记录了 bin-log文件名称才对,比如:

./Centos64-relay-bin.002064
./Centos64-relay-bin.002065
./Centos64-relay-bin.002066
./Centos64-relay-bin.002067
./Centos64-relay-bin.002068
./Centos64-relay-bin.002069
./Centos64-relay-bin.002070

因此,将 Centos64-relay-bin.index 这个文件mv 重命名,然后重启MySQL,重新按照上文从网上照来的的步骤:reset、change master、start 成功搞定!

如果你也遇到类似问题,可以先按照网上提供的三个步骤试试,如果还是和本文类似的报错,请特别看下MySQL数据目录下的这几种文件:

mysql-bin.index

relay-log.info

主机名-relay-bin.index

可以尝试将他们重命名或移走,重启MySQL再走一遍上面的三个步骤应该可以搞定了!

9 条回应
  1. 好文推荐 2016-3-29 · 20:42

    进来看看、代码不是太懂

  2. 微部落博客 2016-3-29 · 22:00

    这是怎么造成的,不进行操作,数据库突然会出错么?

    • Jager 2016-3-29 · 22:46

      一般是文件系统异常造成的,机器陈旧、磁盘老化各种。。

  3. 小C博客 2016-3-29 · 22:06

    表示没遇到这个问题,先来学习下!!

  4. 微博美女 2016-3-30 · 12:50

    学习

  5. 憧憬Licoy 2016-3-31 · 19:06

    Jager博主不是用的阿里云的ecs吗,怎么会出现磁盘老化呢 ❗

  6. Koolight 2016-4-2 · 23:47

    啊啊啊,服务器大姨妈了。

  7. 电影天堂迅雷下载 2016-4-4 · 10:35

    不怎么会代码 但是通过这个可以学习学习

  8. 蜂箭户外弓弩专卖 2016-4-4 · 13:11

    我感觉像看天书一样