千家信息网

mysql中slave_exec_mode如何设置自动跳过同步复制错误

发表于:2026-11-01 作者:千家信息网编辑
千家信息网最后更新 2026年11月01日,小编给大家分享一下mysql中slave_exec_mode如何设置自动跳过同步复制错误,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去
千家信息网最后更新 2026年11月01日mysql中slave_exec_mode如何设置自动跳过同步复制错误

小编给大家分享一下mysql中slave_exec_mode如何设置自动跳过同步复制错误,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

slave_exec_mode设置可以跳过1032(记录没有找到)和1062(主键重复)错误,并记录到错误日志中。

slave_exec_mode和slave_skip_errors作用是一样的,只是slave_exec_mode可以在线动态设置。slave_skip_errors必须添加到配置文件中,重启生效。

备库

mysql> select * from testdb1.student;

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

| id | name | class | score |

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

| 1 | a | 1 | 45 |

| 2 | b | 1 | 46 |

| 3 | c | 2 | 89 |

| 4 | d | 2 | 90 |

| 5 | e | 3 | 67 |

| 6 | f | 3 | 87 |

| 7 | g | 4 | 77 |

| 8 | h | 4 | 91 |

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

8 rows in set (0.00 sec)

mysql> delete from testdb1.student where id >5;

Query OK, 3 rows affected (0.00 sec)

mysql> commit;

Query OK, 0 rows affected (0.00 sec)

#修改参数之前

主库master

mysql> delete from testdb1.student where id >7;

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.56.91

Master_User: rep

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: ray-bin.000008

Read_Master_Log_Pos: 1272

Relay_Log_File: ray-relay-bin.000003

Relay_Log_Pos: 1226

Relay_Master_Log_File: ray-bin.000008

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 Delete_rows event on table testdb1.student; Can't find record in 'student', Error_code: 1032; handler error HA_ERR_END_OF_FILE; the event's master log ray-bin.000008, end_log_pos 1241

Skip_Counter: 0

Exec_Master_Log_Pos: 1065

Relay_Log_Space: 1957

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 Delete_rows event on table testdb1.student; Can't find record in 'student', Error_code: 1032; handler error HA_ERR_END_OF_FILE; the event's master log ray-bin.000008, end_log_pos 1241

Replicate_Ignore_Server_Ids:

Master_Server_Id: 2

Master_UUID: 840f94e0-8ea0-11e5-af92-080027a94012

Master_Info_File: /data/3307/data/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: 151126 12:42:37

Master_SSL_Crl:

Master_SSL_Crlpath:

Retrieved_Gtid_Set:

Executed_Gtid_Set:

Auto_Position: 0

1 row in set (0.00 sec)

mysql> stop slave;

Query OK, 0 rows affected (0.78 sec)

mysql> set global sql_slave_skip_counter=1;

Query OK, 0 rows affected (0.01 sec)

mysql> start slave;

Query OK, 0 rows affected (0.33 sec)

#修改备库参数

mysql> show variables like '%slave_exec_mode%';

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

| Variable_name | Value |

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

| slave_exec_mode | STRICT |

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

1 row in set (0.00 sec)

mysql> set global slave_exec_mode=idempotent;

Query OK, 0 rows affected (0.00 sec)

mysql> show variables like '%slave_exec_mode%';

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

| Variable_name | Value |

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

| slave_exec_mode | IDEMPOTENT |

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

1 row in set (0.00 sec)

主库删除数据

mysql> delete from testdb1.student where id >6;

Query OK, 1 row affected (0.01 sec)

mysql> commit;

Query OK, 0 rows affected (0.00 sec)

备库查看状态和错误日志

mysql> show slave status\G

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

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.56.91

Master_User: rep

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: ray-bin.000008

Read_Master_Log_Pos: 1479

Relay_Log_File: ray-relay-bin.000004

Relay_Log_Pos: 488

Relay_Master_Log_File: ray-bin.000008

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Replicate_Do_DB:

Replicate_Ignore_DB:

Replicate_Do_Table:

Replicate_Ignore_Table:

Replicate_Wild_Do_Table:

Replicate_Wild_Ignore_Table:

Last_Errno: 0

Last_Error:

Skip_Counter: 0

Exec_Master_Log_Pos: 1479

Relay_Log_Space: 1972

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: 0

Master_SSL_Verify_Server_Cert: No

Last_IO_Errno: 0

Last_IO_Error:

Last_SQL_Errno: 0

Last_SQL_Error:

Replicate_Ignore_Server_Ids:

Master_Server_Id: 2

Master_UUID: 840f94e0-8ea0-11e5-af92-080027a94012

Master_Info_File: /data/3307/data/master.info

SQL_Delay: 0

SQL_Remaining_Delay: NULL

Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it

Master_Retry_Count: 86400

Master_Bind:

Last_IO_Error_Timestamp:

Last_SQL_Error_Timestamp:

Master_SSL_Crl:

Master_SSL_Crlpath:

Retrieved_Gtid_Set:

Executed_Gtid_Set:

Auto_Position: 0

1 row in set (0.00 sec)

[root@ray ~]# tail -20f /data/3307/data/mysql_ray.err

2015-11-26 12:50:29 12127 [Warning] Slave SQL: Could not execute Delete_rows event on table testdb1.student; Can't find record in 'student', Error_code: 1032; handler error HA_ERR_END_OF_FILE; the event's master log ray-bin.000008, end_log_pos 1655, Error_code: 1032

注:pos可能对不上,因为截取的问题,不必在意。

以上是"mysql中slave_exec_mode如何设置自动跳过同步复制错误"这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注行业资讯频道!

错误 篇文章 同步 内容 参数 日志 状态 不怎么 作用 动态 只是 大部分 数据 文件 更多 知识 行业 资讯 资讯频道 问题 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 南京欣网互联网络科技 广东猪兼强互联网科技有限公司 科技金融是不是互联网金融 互联网电商科技 互联网金融 科技金融 互联网科技作文 伴你行互联网科技有限公司 镁科技互联网资讯平台 恒生科技互联网指数分析 银川新华互联网科技学校地址 互联网系的金融科技公司 互联网经济与金融科技 宜昌元轩互联网科技有限公司 速维有品互联网信息科技(苏州)有限公司 深圳育鹏互联网科技有限公司招聘 卓翼科技产业互联网合作 互联网金融科技名词解释 南京一网一红互联网科技有限公司 北京军民互联网科技公司 互联网科技自媒体灵感 互联网络科技 互联网科技深圳 疫情对互联网科技公司影响 壕鑫互联网络科技 广州善班互联网科技 科技互联网大厂 萌小萌互联网科技河南有限公司 互联网大会出现的黑科技 中国主要互联网科技公司 如何强化互联网金融科技
0