從庫 show slave status \G 顯示 Slave_IO_Running: No,執行 start slave 報錯:
ERROR 1201 (HY000): Could not initialize master info structure;
more error messages can be found in the MySQL error log
STOP SLAVE;
RESET SLAVE;
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;
若仍報錯,需深入錯誤日志。
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
關鍵字:corrupted double-linked list、failed to stat、relay log space。
檢查數據目錄下 主機名-relay-bin.index(如 Centos64-relay-bin.index),正常應列出 relay log 文件名:
./Centos64-relay-bin.002064
./Centos64-relay-bin.002065
./Centos64-relay-bin.002066
...
實際發現文件內容異常(被寫入了錯誤的二進制數據或截斷)。
cd /data/mysql/data
mv Centos64-relay-bin.index Centos64-relay-bin.index.bak
STOP SLAVE;
RESET SLAVE;
CHANGE MASTER TO ...;
START SLAVE;
SHOW SLAVE STATUS \G 確認 Slave_IO_Running: Yes、Slave_SQL_Running: Yes。mysql-bin.index(主庫二進制日志索引)relay-log.info(從庫中繼日志信息)主機名-relay-bin.index(從庫中繼日志索引)master.info(舊版本主庫信息)這些文件損壞時,重命名或移走後重啟 MySQL,再重新配置主從通常能解決。