slave复制中,常见的错误有:
1032:Can't find record in %s1053:Server shutdown in process
1062:Duplicate entry %s for key %d
1050:Table %s already exists
1051:Unknown table %s
1054:Unknown column %s in %s
1146:Table %s.%s doesn't exists
1236:Fatal error reading binlog
1032,1062,1236错误处理
记录不存在:1032(主库更新或删除的记录在从库上不存在)
看在master上执行了什么
mysqlbinlog --base64-output=decode-rows -vv --start-position='1009144978' --stop-position='1010617671' mysql-bin.000045
将相应的记录在从库上执行
记录不存在:1032(delete情况)
跳过一个事务
传统环境复制:
stop slave;
set global sql_slave_skip_counter = 1;
start slave;
GTID环境复制:
stop slave;
set gtid_next='766d5362-c923-11e6-85b5-000c29de38de:12'; 已执行的加1
begin;commit;
set gtid_next='AUTOMATIC';
start slave;
主键冲突:1062错误
在从库上将相应主键的记录删掉
1236错误:log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master;
show VARIABLES like '%max_allowed_packet%';
set global max_allowed_packet =512*1024*1024;
MySQL5.6针对复制功能提供了新特性:slave支持crash-safe
1.停止slave的MySQL实例2.my.cnf文件中添加
master-info-repository=TABLE
relay-log-info-repository=TABLE
relay-log-recovery
3.重启slave的MySQL实例