| 角色 | OS | MySQL | IP |
|---|---|---|---|
| Master | Windows | 5.0.51 | 192.168.1.156 |
| Slave | Linux | 5.0.67 | 192.168.1.154 |
同步資料庫:account
Slave 兩執行緒:
[mysqld]
server-id = 1
log-bin = d:/log-bin.log
binlog-do-db = account
建立同步專用帳號:
GRANT REPLICATION SLAVE ON *.* TO 'sync_user'@'192.168.1.154' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
[mysqld]
server-id = 2
master-host = 192.168.1.156
master-user = sync_user
master-password = password
master-port = 3306
replicate-do-db = account
account → 還原到 SlaveSHOW MASTER STATUS; 記錄 File、PositionSLAVE STOP;
CHANGE MASTER TO MASTER_LOG_FILE='log-bin.000003', MASTER_LOG_POS=12345;
SLAVE START;
SHOW SLAVE STATUS\G 確認 Slave_IO_Running: Yes、Slave_SQL_Running: Yes現象:Master 修改 log-bin 路徑重啟後,Slave 報錯 Could not find first log file name in binary log index
原因:Slave 的 master.info 記錄了舊 binlog 檔名與位置,路徑變更導致找不到。
解決:停止 Slave → 刪除 master.info → 重啟 Slave → 重新 CHANGE MASTER TO 指向新 binlog 起點。
master.info:記錄 Master 連線資訊、binlog 檔名/位置relay-log.info:記錄 SQL 執行進度relay-log.*:從 Master 複製的中繼日誌