大清早收到一個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再走一遍上面的三個步驟應該可以搞定了!