slave日誌中的錯誤程式碼1:
- [ERROR] Error reading packet from server: Client requested master to start replication from impossible position; the last event was read from `mysql-bin.000016` at 455562731, the last byte read was read from `mysql-bin.000016` at 4. ( server_errno=1236)
- 120725 23:19:17 [ERROR] Slave I/O: Got fatal error 1236 from master when reading data from binary log: `Client requested master to start replication from impossible position; the last event was read from `mysql-bin.000016` at 455562`, Error_code: 1236
解救辦法:
先檢視主伺服器中對應日誌檔案是否有此行,使用的命令是
mysqlbinlog /YOURPATH/`mysql-bin.000016 >>/test
查詢有沒有455562對應的行 或者和這個數字很接近的行 然後使用chang master to 命令跳過這行,命令格式如下
- stop slave;
- CHANGE MASTER TO MASTER_HOST=`192.168.192.45`,MASTER_USER=`XXXX`,MASTER_PASSWORD=`XXXX`,MASTER_LOG_FILE=`mysql-bin.000016`,MASTER_LOG_POS=455678;
- start slave;
如果你找不到455562或者和這個數字很接近的行,你可以使用如下命令檢視`mysql-bin.000016 的行數
- ls -la mysql-bin.000016
如果統計的行數遠遠少於455562,你可以跳過這個日誌,從下一個日誌開始複製,命令如下
- stop slave;
- CHANGE MASTER TO MASTER_HOST=`192.168.192.45`,MASTER_USER=`backup`,MASTER_PASSWORD=`weiphone`,MASTER_LOG_FILE=`mysql-bin.000017`,MASTER_LOG_POS=4;
- start slave;
錯誤型別程式碼2:
mysql slave Error_code: 1062 1054
如果日誌中出現了這樣程式碼,可能是錯誤的select,或update操作,master是跳過這些操作,但是被記錄到了二進位制日誌中,slave會依據二進位制中的語句做相同的動作,就會報錯,知道原理了要做的操作就很簡單了
- stop slave;
- set gloable sql_slave_skip_counter=n; //n為你想跳過錯誤語句的個數
- start slave;
如果你不想再遇到這種錯誤,可以寫到slave配置檔案中格式如下:
- slave_skip_errors = 1062
- slave_skip_errors = all //跳過所有型別的錯誤碼