公司的 mysql slave 主機突然掛點資料無法同步。
首先查看 Slave status 發現 Slave_IO_Running 和 Slave_SQL_Running 都沒有正常的運作
Slave status
Slave_IO_Running No
Slave_SQL_Running No
接著查看 mysql 的 mysqld.log 是否有詳細的錯誤訊息
mysqld.log
16:07:26 [ERROR] Error reading master configuration
解決方法
1 service mysqld stop ,停止 mysql 服務
2 刪除所有 replication 相關檔案
master.info
relay-log.info
mysqld-relay-bin.xxxxx
mysql-bin.xxxx
mysql-bin.index
mysqld-relay-bin.index
mysql-relay-bin.index
ibdata1
ib_logfile0
ib_logfile1
3 service mysqld start,啟動 mysql 服務
4 mysql -u root -p,登入 mysql
5 重新設定 replication
reset slave;
CHANGE MASTER TO MASTER_HOST='xxx',
MASTER_USER='xxx',
MASTER_PASSWORD='xxx',
MASTER_LOG_FILE='xxx',
MASTER_LOG_POS=xxx;
6 啟動 slave 機制
start slave;
7 查看 slave 狀態
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: xxx.xxx.xxx.xxx
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000300
Read_Master_Log_Pos: 248335779
Relay_Log_File: mysqld-relay-bin.000008
Relay_Log_Pos: 246297247
Relay_Master_Log_File: mysql-bin.000300
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: 246297102
Relay_Log_Space: 248336123
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: 212
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)