mysql GTID主从复制 跳过复制错误

在mysqlGTID下,使用

SET GLOBAL SQL_SLAVE_SKIP_COUNTER = n

会产生如下错误

ERROR 1858 (HY000): sql_slave_skip_counter can not be set when the server is running with @@GLOBAL.GTID_MODE = ON. Instead, for each transaction that you want to skip, generate an empty transaction with the same GTID as the transaction

根据报错提示,我们可以看到我们可以通过执行空事务来跳过复制错误

STOP SLAVE;
SET GTID_NEXT="7d72f9b4-8577-11e2-a3d7-080027635ef5:5";
BEGIN; COMMIT;
SET GTID_NEXT="AUTOMATIC";
START SLAVE;

但是当需要跳过的事务较多时,这个方法比较麻烦。可以使用MySQL Utilities中的mysqlslavetrx跳过错误
mysqlslavetrx使用说明

mysqlslavetrx --gtid-set=87fd24be-683d-11e6-ba97-1418774c98d8:3-40 --slaves=root:beijing@localhost:/home/mysql/my3306.sock

参数说明:

 --dryrun

Execute the utility in dry-run mode, show the transactions (GTID) that would have been skipped for each slave but without effectively skipping them. This option is useful to verify if the correct transactions will be skipped.

 --gtid-set=<gtid-set>

Set of Global Transaction Identifiers (GTID) to skip.

 --help

Display a help message and exit.

 --license

Display license information and exit.

 --slaves=<slaves_connections>

Connection information for slave servers. List multiple slaves in comma-separated list.

To connect to a server, it is necessary to specify connection parameters such as the user name, host name, password, and either a port or socket. MySQL Utilities provides a number of ways to supply this information. All of the methods require specifying your choice via a command-line option such as --server, --master, --slave, etc. The methods include the following in order of most secure to least secure.

Use login-paths from your .mylogin.cnf file (encrypted, not visible). Example : <login-path>[:<port>][:<socket>]

Use a configuration file (unencrypted, not visible) Note: available in release-1.5.0. Example : <configuration-file-path>[:<section>]

Specify the data on the command-line (unencrypted, visible). Example : <user>[:<passwd>]@<host>[:<port>][:<socket>]

 --ssl-ca

The path to a file that contains a list of trusted SSL CAs.

 --ssl-cert

The name of the SSL certificate file to use for establishing a secure connection.

 --ssl-key

The name of the SSL key file to use for establishing a secure connection.

 --ssl

Specifies if the server connection requires use of SSL. If an encrypted connection cannot be established, the connection attempt fails. Default setting is 0 (SSL not required).

 --verbose, -v

Specify how much information to display. Use this option multiple times to increase the amount of information. For example, -v = verbose, -vv = more verbose, -vvv = debug.

 --version

Display version information and exit.

也可以通过

set global gtid_purged='887fd24be-683d-11e6-ba97-1418774c98d8:3-40';

跳过已经purge的部分,之后重新开启复制即可。
完成这些操作后,如果对数据一致性的问题有顾虑,可以通过 pt-table-checksum来进行一致性检查。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值