MySQL主從報錯解決:Failed to initialize the master info structure
阿新 • • 發佈:2022-05-05
大清早收到一個 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 檔案中出現異常內容:
這個檔案正常情況應該是記錄了 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 再走一遍上面的三個步驟應該可以搞定了!