在重启了外国B的服务器后,发现国内A数据库同步突然停止了,导致国内A服务器复制失败,如下:
国内A就报下面的错误:
090910 22:47:18 [ERROR] Error reading packet from server: Client requested master to start replication from impossible position ( server_errno=1236)
090910 22:47:18 [ERROR] Got fatal error 1236: Client requested master to start replication from impossible position from master when reading data from binary log
090910 22:47:18 [Note] Slave I/O thread exiting, read up to log mysql-bin.000008, position 753871857
国外B是正常的。
然后我上网找一些一些资料.
出现这样的错误是由于同步数据的位出现错误.
也就是错误提示里说明的问题.
登陆到国外B上面用mysqlbinlog查看
[root@xxx mysql]# mysqlbinlog –start-position=753871857 mysql-bin.000008
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=OLD_COMPLETION_TYPE*/;
确实没有这个位置,
为了进一步确认,我将binlog dump成文本文件
mysqlbinlog mysql-bin.000008 > 1.txt
开打1.txt文件
# at 753870260
#080724 16:21:25 server id 2 end_log_pos 753870665 Query thread_id=185 exec_time=0 error_code=0
SET TIMESTAMP=1216887685/*!*/;
insert into im_offlinemsg_07(gmt_create,type,from_id,to_id,content)values(sysdate(),0,cnalichnzizufhm,cnalichnluelee,AAFcQzB4NzBmZlxGy87M5VxUob7Iureiob9cQzBcUzB4OS4weGI0XEbLzszlXFRodHRwOi8vYmJzLmticmVuLmNuL3RhaXdhbi5odG1sDQq7qMHLztLV+9X70rvN7cnPtcTKsbzksKGjrNbV09q447rDwcujrL/syKW/tL+0o6y8×7XDwfS49tHUxbZcVC86JFxULzpnaXJs)/*!*/;
# at 753870665
#080724 16:21:25 server id 2 end_log_pos 753870692 Xid = 35714167
COMMIT/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
找到他相接近的位置就可以了.
发现mysql-bin.000008里面最接近753871857的一个有效的position是753870665。好像有error_code是无效的。
然后在国外B上执行 再change master命令命令内容如下,将位置指定为这个最后位置:
stop slave;
CHANGE MASTER TO MASTER_HOST='xxx.xxx.xxx.xxx',
MASTER_USER='root',
MASTER_PASSWORD='******',
MASTER_LOG_FILE='mysql-bin.000008',
MASTER_LOG_POS=753870665;
start slave;
问题就解决了。