Mysql Replication:Error 整理

server-id 相同
参考:http://www.penglixun.com/tech/database/mysql_multi_slave_same_serverid.html
不断的被Master Server给kill掉,binlog丢失
原因:slave注册时会先从slave list中kill
掉,然后插入自己的信息。
        当s2连接时,会将s1删除,然后master将binlog发送给s2
        当s1连接时,会将s2删除,然后master将binlog发送给s1

Last_IO_Errno: 1062
原因:出现重复数据。
解决办法:设置sql_slave_skip_counter进行跳过。但需要确定这样操作没有其他隐患,另外跳过的是事务数,并不是sql数


Last_IO_Errno: 1236
Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'
原因:主库上的binlog文件已经不存在但是在index file中确有相应记录存在。
解决办法:
1:master的binlog已经由于其超期而被删掉。只能重做
2:MASTER的binlog还没有刷新到磁盘,但已经发送到slave,此时master宕机,slave重连必然报此类错误。指向master下一个positioin位置

Last_Errno: 28
        Last_Error: Error in Append_block event: write to '/tmp/SQL_LOAD-32343798-72213798-1.data' failed
    原因:主库执行load data infile,同步到从库后load data infile存放的文件默认是放在/tmp(由参数slave_load_tmpdir控制),而/tmp空间不够因此报错。

    解决方法: 将从库上slave_load_tmpdir设置到一个磁盘空间足够大的分区就行。


Last_SQL_Errno: 1677
Last_SQL_Error: Column 1 of table 'test.t' cannot be converted from type 'int' to type 'bigint(20)'
原因:这个表t进行DML操作时,主从上表结果不一致(主是int,从是bigint),会导致数据截断之类的问题。
在从库修改列属性后,切换主从,新主(旧从)的数据同步到新从(旧主)时,只在binlog_format=ROW的情况会产生此错误
解决方法:通过参数slave_type_conversions进行控制,它有三种取值:
ALL_LOSSY:仅支持有损转换,什么叫有损?比如一个值本来是bigint存储为9999999999999,现在转换为int类型势必会要截断从而导致数据不一致。
ALL_NON_LOSSY:仅支持无损转换,只能在无损的情况下才能进行转换
ALL_LOSSY,ALL_NON_LOSSY:有损/无算转换都支持
空,即不设置这个参数:必须主从的字段类型一模一样。



Last_SQL_Errno: 1194
Last_SQL_Error: Error 'Table 'traincenter' is marked as crashed and should be repaired' on query. Default database: 'basketballman'. Query: 'update traincenter set points='4',pointstime='1361912066'  where uid = '1847482697' limit 1'
原因:myisam表traincenter损坏
解决办法:直接repair table即可。




Last_Errno: 1053
Last_Error: Query partially completed on the master (error on master: 1053) and was aborted. There is a chance that your master is inconsistent at this point. If you are sure that your master is ok, run this query manually on the slave and then restart the slave with SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE; . Query: 'insert into ...
原因:myisam不支持事务所以可能存在一个查询完成一部分然后失败的情况。
解决方法:最安全的办法校验此表pt-check-table,


Last_SQL_Errno: 1366
Last_SQL_Error: Error 'Incorrect string value: '\xB2\xBD\xD6\xE8\xA3\xBA...' for column 'VALUE_STR' at row 1' on query. xxxx
原因:主从字符集、表定义字符集、客户端插入时字符集不一致
解决方案:修正字符集,保持一致; 


# 此错误待验证
Last_SQL_Errno: 1666
Last_SQL_Error: Error executing row event: 'Cannot execute statement: impossible to write to binary log since statement is in row format and BINLOG_FORMAT = STATEMENT.' 
原因:binlog模式不同,一个ABC结构的复制,A是MIXED,B、C是statement,所以当B尝试重做A过来的relay log,然后记录binlog(传给C)时发现relay log的binlog_format与自己设定的binlog_format不一致。
解决办法:
1:更改BC的binlog_format=MIXED。



请使用浏览器的分享功能分享到微信等