背景:有3台服务器,做了1主2从
主:192.168.0.2
从:192.168.0.9/192.168.0.6

先从同好0.6的数据,再启动0.9,同步数据时候,Seconds_Behind_Master的值一直保持某个数值,日志里面产生了几万个localhost-relay-bin.*的文件,日志报如下错误:
121101 11:38:52 [Note] Slave: received end packet from server, apparent master shutdown: 
121101 11:38:52 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'mysql-bin.000002' at postion 188278072
121101 11:38:52 [Note] Slave: received end packet from server, apparent master shutdown: 
121101 11:38:52 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'mysql-bin.000002' at postion 188279159
121101 11:38:52 [Note] Slave: received end packet from server, apparent master shutdown: 
121101 11:38:52 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'mysql-bin.000002' at postion 188279159
121101 11:38:52 [Note] Slave: received end packet from server, apparent master shutdown: 
121101 11:38:52 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'mysql-bin.000002' at postion 188280253

从网上搜索,是说由于server-id相同而造成的。因为搭建环境之后,/etc/my.cnf是直接从0.6上面复制过来的

解决方法:
修改0.9上面的server-id=3,停数据库,把datadir里面的日志全部删除,重启数据库,重新同步,OK