MySQL slave error 1677

来源:互联网 发布:淘宝站外网站 编辑:程序博客网 时间:2024/06/16 13:28

今天一台slave突然报错,最终定位是有两个系统,有一个系统写入不规范引起。这边不详细介绍这个问题,记录一下和1677相关一个bug(不算?)一些参数

Last_SQL_Errno: 1677

Last_SQL_Error: Column 0 of table ‘aa.heartbeat’ cannot be converted from type ‘smallint’ to type ‘int(11)’

@Shane Bester 建议slave_type_conversions=ALL_NON_LOSSY,能解决这个问题。以前没有关注过这个参数,我们线上环境都没有设置。

slave_type_conversions:在slave上进行字段类型转化的,因为主备之间可能在某些情况下,有相同的表名,但字段多少、字段类型、字段顺序不一样,可能导致1677错误,这时需要设置相应参数来进行处理。

MySQL 5.5.3版本开始,支持属性提升特性,包括有损转化和无损转换

参数支持值:

1、ALL_LOSSY:可以将int型转化成tinyint,存在截断的情况,有损转化

2、ALL_NON_LOSSY:不允许出现截断情况,slave的类型范围大于master方可转化。设置这个参数后,如果存在截断情况,slave会报错

3、以后两个参数都设置,就存在截断的情况

4、未设置,主备之间必须一致

在slave上类型转化需要注意:

Whether you use statement-based or row-based replication, the slave’s copy of the table cannot contain more columns than the master’s copy if you wish to employ attribute promotion.

参考:http://dev.mysql.com/doc/refman/5.5/en/replication-features-differing-tables.html#replication-features-attribute-promotion

0 0
原创粉丝点击