wKioL1gapS3yFcPpAAA4eVx2Dz8496.jpg

3分钟解决MySQL 1032主从错误

Part1:写在最前

1032错误----现在生产库中好多数据,在从库误删了,生产库更新后找不到了,现在主从不同步了,再跳过错误也没用,因为没这条,再更新还会报错

解决方案

Part1:临时方案

mysql> stop slave;

Query OK, 0 rows

affected (0.00 sec)

mysql> set global sql_slave_skip_counter=1;

Query OK, 0 rows

affected (0.00 sec)

mysql> start slave;

Query OK, 0 rows

affected (0.00 sec)

Part2:永久方案

end_log_pos 有了它,根据pos值,直接就能找到,找到delete那条数据,反做(变成insert)

故障模拟

HE1从库误删

mysql> delete from helei where id=3;

Query OK, 1 row

affected (0.29 sec)

mysql> select * from helei;

+----+------+

| id | text |

+----+------+

|  1 | aa

|

|  2 | bb

|

|  4 | ee

|

|  5 | ff

|

|  6 | gg

|

|  7 | hh

|

+----+------+

6 rows in set (0.00

sec)

mysql> show slave status\G;

***************************

1. row ***************************

Slave_IO_State: Waiting for

master to send event

Master_Host: 192.168.1.250

Master_User: mysync

Master_Port: 2503306

Connect_Retry: 60

Master_Log_File: mysql-bin.000005

Read_Master_Log_Pos: 3711

Relay_Log_File:

HE1-relay-bin.000007

Relay_Log_Pos: 484

Relay_Master_Log_File: mysql-bin.000005

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

此时从库状态是正常的,但一旦主库对该条记录进行操作

HE3主库更新从库刚刚误删的数据

mysql> update helei set text='ccc' where id=3;

Query OK, 1 row

affected (0.01 sec)

Rows matched: 1  Changed: 1

Warnings: 0

mysql> select * from helei;

+----+------+

| id | text |

+----+------+

|  1 | aa

|

|  2 | bb

|

|  3 | ccc

|

|  4 | ee

|

|  5 | ff

|

|  6 | gg

|

|  7 | hh

|

+----+------+

7 rows in set (0.00

sec)

HE1从库报错

mysql> show slave status\G;

***************************

1. row ***************************

Slave_IO_State: Waiting for

master to send event

Master_Host: 192.168.1.250

Master_User: mysync

Master_Port: 2503306

Connect_Retry: 60

Master_Log_File: mysql-bin.000005

Read_Master_Log_Pos: 3918

Relay_Log_File:

HE1-relay-bin.000007

Relay_Log_Pos: 484

Relay_Master_Log_File: mysql-bin.000005

Slave_IO_Running: Yes

Slave_SQL_Running: No

Replicate_Do_DB:

Replicate_Ignore_DB:

Replicate_Do_Table:

Replicate_Ignore_Table:

Replicate_Wild_Do_Table:

Replicate_Wild_Ignore_Table:

Last_Errno: 1032

Last_Error: Could not

execute Update_rows event on table test.helei; Can't find record in 'helei',

Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log

mysql-bin.000005, end_log_pos 3887

Skip_Counter: 0

Exec_Master_Log_Pos: 3711

Relay_Log_Space: 1626

Until_Condition: None

Until_Log_File:

Until_Log_Pos: 0

Master_SSL_Allowed: No

Master_SSL_CA_File:

Master_SSL_CA_Path:

Master_SSL_Cert:

Master_SSL_Cipher:

Master_SSL_Key:

Seconds_Behind_Master: NULL

Master_SSL_Verify_Server_Cert:

No

Last_IO_Errno: 0

Last_IO_Error:

Last_SQL_Errno: 1032

Last_SQL_Error: Could not execute Update_rows event on table test.helei;

Can't find record in 'helei', Error_code: 1032; handler error

HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000005, end_log_pos 3887(这个mysql-bin.000005,end_log_pos

3887是主库的)

Replicate_Ignore_Server_Ids:

Master_Server_Id: 2503306

Master_UUID:

f7c96432-f665-11e5-943f-000c2967a454

Master_Info_File:

/data/mysql/master.info

SQL_Delay: 0

SQL_Remaining_Delay: NULL

Slave_SQL_Running_State:

Master_Retry_Count: 86400

Master_Bind:

Last_IO_Error_Timestamp:

Last_SQL_Error_Timestamp: 160331 09:25:02

Master_SSL_Crl:

Master_SSL_Crlpath:

Retrieved_Gtid_Set:

Executed_Gtid_Set:

Auto_Position: 0

1 row in set (0.00

sec)

此时主从又不同步了,如果还去执行跳过错误操作,主从恢复同步,而且状态均为yes,但!这并不能解决该问题,如果主库又更新该条记录,那么还是会报相同错误,而且pos号还会变,这就导致了恢复时你不知道前一条的pos号,导致丢失数据。

mysql> stop slave;

Query OK, 0 rows

affected (0.00 sec)

mysql> set global sql_slave_skip_counter=1;

Query OK, 0 rows

affected (0.00 sec)

mysql> start slave;

Query OK, 0 rows

affected (0.00 sec)

mysql> select * from helei;

+----+--------+

| id | text   |

+----+--------+

|  1 | aa

|

|  2 | bb

|

|  4 | ee

|

|  5 | ff

|

|  6 | gg

|

|  7 | hh

|

|  8 | helei1 |

+----+--------+

7 rows in set (0.00 sec)

mysql> show slave status\G;

***************************

1. row ***************************

Slave_IO_State: Waiting for

master to send event

Master_Host: 192.168.1.250

Master_User: mysync

Master_Port: 2503306

Connect_Retry: 60

Master_Log_File: mysql-bin.000005

Read_Master_Log_Pos: 4119

Relay_Log_File:

HE1-relay-bin.000008

Relay_Log_Pos: 283

Relay_Master_Log_File: mysql-bin.000005

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

这里虽然通过跳过错误达到恢复主从同步,但如果主库又对该条记录更新

mysql> update helei set text='cccc' where id=3;

Query OK, 1 row

affected (0.00 sec)

mysql> show slave status\G;

***************************

1. row ***************************

Slave_IO_State: Waiting for

master to send event

Master_Host: 192.168.1.250

Master_User: mysync

Master_Port: 2503306

Connect_Retry: 60

Master_Log_File: mysql-bin.000005

Read_Master_Log_Pos: 4328

Relay_Log_File:

HE1-relay-bin.000008

Relay_Log_Pos: 283

Relay_Master_Log_File: mysql-bin.000005

Slave_IO_Running: Yes

Slave_SQL_Running: No

Replicate_Do_DB:

Replicate_Ignore_DB:

Replicate_Do_Table:

Replicate_Ignore_Table:

Replicate_Wild_Do_Table:

Replicate_Wild_Ignore_Table:

Last_Errno: 1032

Last_Error: Could not execute Update_rows event on table test.helei;

Can't find record in 'helei', Error_code: 1032; handler error

HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000005, end_log_pos 4297

Skip_Counter: 0

Exec_Master_Log_Pos: 4119

Relay_Log_Space: 1435

Until_Condition: None

Until_Log_File:

Until_Log_Pos: 0

Master_SSL_Allowed: No

Master_SSL_CA_File:

Master_SSL_CA_Path:

Master_SSL_Cert:

Master_SSL_Cipher:

Master_SSL_Key:

Seconds_Behind_Master: NULL

Master_SSL_Verify_Server_Cert:

No

Last_IO_Errno: 0

Last_IO_Error:

Last_SQL_Errno: 1032

Last_SQL_Error: Could not execute Update_rows event on table test.helei;

Can't find record in 'helei', Error_code: 1032; handler error

HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000005, end_log_pos 4297

Replicate_Ignore_Server_Ids:

Master_Server_Id: 2503306

Master_UUID:

f7c96432-f665-11e5-943f-000c2967a454

Master_Info_File:

/data/mysql/master.info

SQL_Delay: 0

SQL_Remaining_Delay: NULL

Slave_SQL_Running_State:

Master_Retry_Count: 86400

Master_Bind:

Last_IO_Error_Timestamp:

Last_SQL_Error_Timestamp: 160331 09:33:34

Master_SSL_Crl:

Master_SSL_Crlpath:

Retrieved_Gtid_Set:

Executed_Gtid_Set:

Auto_Position: 0

©著作权归作者所有:来自51CTO博客作者dbapower的原创作品,如需转载,请注明出处,否则将追究法律责任

mysql错误主从troubleshooting

mysql 1032错误_3分钟解决MySQL 1032 主从错误相关推荐

  1. mysql主从1594错误_3分钟解决MySQL主从1594错误

    3分钟解决MySQL主从1594错误简介 Part1:写在最前 1594这个错误看起来挺严重的,会提示你binlog文件或者Relay log损坏了,例如binary log is corrupted ...

  2. 3分钟解决MySQL 1032 主从错误(转)

    转自  https://blog.51cto.com/suifu/1845457 3分钟解决MySQL 1032主从错误 Part1:写在最前 1032错误----现在生产库中好多数据,在从库误删了, ...

  3. 3分钟解决MySQL 1032 主从错误

    3分钟解决MySQL 1032主从错误 Part1:写在最前 1032错误----现在生产库中好多数据,在从库误删了,生产库更新后找不到了,现在主从不同步了,再跳过错误也没用,因为没这条,再更新还会报 ...

  4. mysql unrecognized_service mysql start出错,mysql启动不了,解决mysql: unrecognized service错误...

    service mysql start出错,mysql启动不了,解决mysql: unrecognized service错误的方法如下: [root@ctohome.com ~]# service ...

  5. MySQL连接问题【如何解决MySQL连接超时关闭】

    --MySQL连接问题[如何解决MySQL连接超时关闭] ------------------------------------------------转载 最近做网站有一个站要用到WEB网页采集器 ...

  6. mysql 授权 失败_完美解决mysql客户端授权后连接失败的问题

    在本地(192.168.1.152)部署好mysql环境,授权远程客户机192.168.1.%连接本机的mysql,在iptables防火墙也已开通3306端口. 如下: mysql> sele ...

  7. mysql占用多少内存_解决mySQL占用内存超大问题

    解决mySQL占用内存超大问题 解决mySQL占用内存超大问题 为了装mysql环境测试,装上后发现启动后mysql占用了很大的虚拟内存,达8百多兆.网上搜索了一下,得到高人指点my.ini.再也没见 ...

  8. mysql数据库连接过多_轻松解决MYSQL数据库连接过多的错误

    1.数据库系统允许的最大可连接数max_connections.这个参数是可以设置的.如果不设置,默认是100.最大是16384. 2.数据库当前的连接线程数threads_connected.这是动 ...

  9. mysql数据库断开连接_解决mysql服务器在无操作超时主动断开连接的情况

    我们在使用mysql服务的时候,正常情况下,mysql的设置的timeout是8个小时(28800秒),也就是说,如果一个连接8个小时都没有操作,那么mysql会主动的断开连接,当这个连接再次尝试查询 ...

最新文章

  1. Unofficial Windows Binaries for Python Extension Packages
  2. 《剑指offer》数组中只出现一次的数字
  3. 【剑指offer】面试题48. 最长不含重复字符的子字符串(java)
  4. NumPy学习(索引和切片,合并,分割,copy与deep copy)
  5. python+request+Excel做接口自动化测试
  6. ArcMAP 用不同颜色区分地类
  7. 【BP数据预测】基于matlab狼群算法优化BP神经网络数据预测【含Matlab源码 658期】
  8. 12月第1周网络安全报告:85.9万境内主机感染病毒
  9. 【嵌入式】基于ARM的嵌入式Linux开发总结
  10. 使用planetaryjs插件实现3维地球仪效果
  11. 常用的基础英文字体推荐
  12. 山东省教师教育网-学习课程
  13. Springboot-Retry组件@Recover失效问题解决
  14. 获取优酷网、土豆网、56网的视频缩略图
  15. 软件测试中的白盒测试分析
  16. 拯救者进入BIOS模式
  17. 单片机c语言置位程序流程图,单片机c语言教程第十二章--C51开关分支语句
  18. 一个tesseract ocr box 文件查看toy,python
  19. Joinquant 指数10大持仓等比买入
  20. java全栈系列之JavaSE-面向对象(接口定义与实现)042

热门文章

  1. 搜索思维[PPT制作]
  2. 5款主流智能音箱入门款测评:苹果小米华为天猫小度,谁的表现更胜一筹?
  3. 《Google SRE》读后感
  4. 1期精彩推荐:如何应对工作中的冲突?
  5. openwrt广告屏蔽大师修复补丁luci-app-adbyby plus + lite
  6. CTFshow - 七夕杯复现
  7. 微信小程序二手交易系统ssm框架——计算机毕业设计
  8. 百度图片搜索搜出大量色情图片,原因不明
  9. 下载百度编辑器ueditor
  10. re模块与正则表达式 1