主从同步描述如下:

由于主机故障,导致从库的mysql实例重启了。重启后,从库的slave status报下面的错误:

Last_SQL_Errno: 1062
Last_SQL_Error: Could not execute Write_rows event on table qrcode.t_qcd_item; Duplicate entry '2861768' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log mysql-bin.000005, end_log_pos 6000458

原因是:

从库已执行该语句,但是未记录在relay log中。导致重启后又重新同步数据了,报1062主键冲突

解决方式:

跳过错误,重新同步.

no.1 修改配置文件,在mysqld下添加

slave_skip_errors = 1062

重启服务器,然后现实中,生产服务器并不能随意重启,所以只能用第二中方案

no.2

SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;

跳过这个错误,如果说,重复的数据有多条N,则SET GLOBAL SQL_SLAVE_SKIP_COUNTER=N;

 

相关文章:

  • 2022-01-20
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2022-12-23
  • 2022-12-23
  • 2022-02-12
  • 2021-12-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-24
  • 2021-09-30
  • 2022-12-23
相关资源
相似解决方案