mysql中使 gtid 复制跳过错误的方法


当前第2页 返回上一页

解决方法一:

(1)停止slave进程

1

2

3

4

5

6

7

8

9

10

mysql> STOP SLAVE;

(2)设置事务号,事务号从Retrieved_Gtid_Set获取

在session里设置gtid_next,即跳过这个GTID

mysql> SET @@SESSION.GTID_NEXT= '8f9e146f-0a18-11e7-810a-0050568833c8:4'

(3)设置空事物

mysql> BEGIN; COMMIT;

(4)恢复事物号

mysql> SET SESSION GTID_NEXT = AUTOMATIC;

(5)启动slave进程

mysql> START SLAVE;


解决办法二:重置master方法跳过错误

1

2

3

4

mysql>  STOP SLAVE;

mysql> RESET MASTER;

mysql>   SET @@GLOBAL.GTID_PURGED ='8f9e146f-0a18-11e7-810a-0050568833c8:1-4'

mysql>  START SLAVE;

上面这些命令的用意是,忽略8f9e146f-0a18-11e7-810a-0050568833c8:1-4 这个GTID事务,下一次事务接着从 5 这个GTID开始,即可跳过上述错误。

解决办法三:使用pt-slave-restart工具

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

pt-slave-restart工具的作用是监视某些特定的复制错误,然后忽略,并且再次启动SLAVE进程(Watch and restart MySQL replication after errors)。

忽略所有1062错误,并再次启动SLAVE进程

[root@dgt mysql]# pt-slave-resetart -S /var/lib/mysql/mysql.sock ―error-numbers=1062

检查到错误信息只要包含 test.t1,就一概忽略,并再次启动 SLAVE 进程

[root@dgt mysql]# pt-slave-resetart -S /var/lib/mysql/mysql.sock  ―error-text=”test.t1”

下面举例解决错误问题号

            Last_SQL_Error: Could not execute Delete_rows event on table test.t; Can't find record in 't', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000028, end_log_pos 1862

  Replicate_Ignore_Server_Ids:

             Master_Server_Id: 2

                  Master_UUID: 8f9e146f-0a18-11e7-810a-0050568833c8

             Master_Info_File: /var/lib/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: 170421 17:45:11

               Master_SSL_Crl:

           Master_SSL_Crlpath:

           Retrieved_Gtid_Set: 8f9e146f-0a18-11e7-810a-0050568833c8:1-7

            Executed_Gtid_Set: 8f9e146f-0a18-11e7-810a-0050568833c8:1-6,

f7c86e19-24fe-11e7-a66c-005056884f03:1

                Auto_Position: 0

         Replicate_Rewrite_DB:

                 Channel_Name:

           Master_TLS_Version:

1 row in set (0.00 sec)

[root@dgt mysql]# pt-slave-restart  -S  /var/lib/mysql/mysql.sock   --error-numbers=1032   --user=root --password='bc.123456'

2017-04-21T17:53:27 S=/var/lib/mysql/mysql.sock,p=...,u=root mysql-bin.000015         620 1032

2017-04-21T17:54:31 S=/var/lib/mysql/mysql.sock,p=...,u=root mysql-bin.000015        1140 1032

参数解释:

1

2

3

4

5

6

7

8

9

--slave-password=s         Sets the password to be used to connect to the slaves

--slave-user=s         Sets the user to be used to connect to the slaves

--sleep=i            Initial sleep seconds between checking the slave ( default 1)

--socket=s             -S  Socket file to use for connection=

--password=s             -p  Password to use when connecting

pt-slave-resetart             -S./mysql.sock ―error-numbers=1032

--error-numbers=h         Only restart this comma-separated list of errors

--host=s             -h  Connect to host

--user=s             -u  User for login if not current user

以上就是mysql中使 gtid 复制跳过错误的方法的详细内容,更多文章请关注木庄网络博客!!

返回前面的内容

相关阅读 >>

mysql 动态生成测试数据

mysql数据库面试必备之三大log介绍

mysql修改root密码的多种方法介绍

mysql是一种什么语言?

mysql的一些功能实用的linux shell脚本分享

mysql5.7中的json基本操作指南

centos7下和linux下安装mysql有什么区别

mysql如何删除重复数据

如何在mac上安装mysql

mysql"军规"

更多相关阅读请进入《mysql》频道 >>


数据库系统概念 第6版
书籍

数据库系统概念 第6版

机械工业出版社

本书主要讲述了数据模型、基于对象的数据库和XML、数据存储和查询、事务管理、体系结构等方面的内容。



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...