MySQL 错误集-汇总

Q&A:html

MySQl报错之@@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_MODE = ONnode

导入的时候加入-f参数便可 

缘由分析:导出原系统开启GTID模式,而导入库没有开启GTID模式

 

Q&A:mysql

ERROR 1840 (HY000) at line 24: @@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_EXECUTED is empty.sql

【解决方案】
方法一:reset mater
这个操做能够将当前库的GTID_EXECUTED值置空
方法二:--set-gtid-purged=off
在dump导出时,添加--set-gtid-purged=off参数,避免将gtid信息导出

 

Q&A:app

Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 1 failed executing transaction 'ad904b26-5128-11e9-92eb-0242c0a80015:3' at master log binlog.000005, end_log_pos 975. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any.工具

【解决方案】
查看形成问题的SQL:
mysqlbinlog --no-defaults --base64-output=DECODE-ROWS --verbose node2-relay-bin.000002 > /tmp/mysqlbin.log
方法一:
STOP SLAVE;
SET @@SESSION.GTID_NEXT = '8fc8d9ac-a62b-11e6-a3ee-a4badb1b4a00:7649';
BEGIN; COMMIT;
SET @@SESSION.GTID_NEXT = AUTOMATIC;
START SLAVE;
方法二:
##GTID模式下的复制,sql_slave_skip_counter是不支持的
set global slave_exec_mode='IDEMPOTENT';##设置成IDEMPOTENT模式可让从库避免1032(从库上不存在的键)和1062(重复键,须要存在主键或则惟一键)的错误,该模式只有在ROW EVENT的binlog模式下生效,在STATEMENT EVENT的binlog模式下无效
stop slave;
start slave;
set global slave_exec_mode='STRICT'; 
参考来源:http://www.cnblogs.com/zhoujinyi/p/8035413.html

再经过pt-table-checksum和 pt-table-sync作数据一致性处理

建立检查帐号:
GRANT SELECT, PROCESS, SUPER, REPLICATION SLAVE,CREATE,DELETE,INSERT,UPDATE ON *.* TO 'pt_checksum' IDENTIFIED BY '1qaz!QAZ';

检查是否有差别:
pt-table-checksum h='192.168.0.21',u='pt_checksum',p='1qaz!QAZ',P=3306 -d gtid --tables=t --nocheck-replication-filters --replicate=percona.checksums --no-check-binlog-format
--[no]check-binlog-format        #默认会检查binlog-format,若是不是statment,就会报错退出,想避免该检查能够设置--no-check-binlog-format
--replicate                      #用来指定存放计算结果的表名, 默认是percona.checksums,工具会默认自动建立库percona和表checksums并将checksum的检查结果输入到这个表中
--[no]check-replication-filters  #默认在检查到在主从复制过程当中有被用..ignore..过滤掉的表,检查会中断并退出,若是想避开这个检查能够设置--no-check-replication-filters
参考来源:https://www.cnblogs.com/xiaoyanger/p/5584554.html

咱们使用pt-table-sync工具还同步这张表的数据:
pt-table-sync --charset=utf8 --print --no-check-slave -d gtid -t t h=192.168.0.21,u='pt_checksum',p='1qaz!QAZ',P=3306 h=192.168.0.22,u='pt_checksum',p='1qaz!QAZ',P=3306 ##前面填主库的内容,后面填从库的内容
--no-check-slave                 #不检查desitination是否为从库
--print                          #打印差别变动语句
--execute                        #执行差别变动语句
执行变动能够直接执行差别变动SQL或者经过如下语句执行:
pt-table-sync --charset=utf8 --execute --no-check-slave -d gtid -t t h=192.168.0.21,u='pt_checksum',p='1qaz!QAZ',P=3306 h=192.168.0.22,u='pt_checksum',p='1qaz!QAZ',P=3306

注意:若是是sync主从数据,只有当须要sync的表都有惟一键(主键或惟一索引),才能使用--sync-to-master and/or --replicate。(没有惟一键,则只能在desitination上直接修改,而指定--sync-to-master and/or –replicate时只能在主库上修改),
若是sync主从时没有指定--replicate或者--sync-to-master则全部修改都在从库上执行(不论表上是否有惟一键)
相关文章
相关标签/搜索