GTID复制报错处理:Last_Error: Error 'Can't drop database 'test'; database doesn't exist' on query
创建GTID主从连接:
mysql> change master to master_host='master_id', master_port=3306, master_user='user', master_password='password', master_auto_position=1;
报错显示:
Slave_IO_Running: Yes
Slave_SQL_Running: No
Last_Error: Error 'Can't drop database 'test'; database doesn't exist' on query. Default database: 'test'. Query: 'drop database test'
Retrieved_Gtid_Set: 988b8684-3e21-22e6-a801-24505689c77d:1-9
Executed_Gtid_Set:
两个新实例启动后我预先做了一些安全处理,然后就直接在从库执行change master,导致主库上的日志在从库里执行不了,需要把无法执行的日志都跳过!
机械的搬运老师上课讲的内容如下:
mysql> stop slave;
Query OK, 0 rows affected (0.00 sec) mysql> set gtid_next="988b8684-3e21-22e6-a801-24505689c77d:9";
Query OK, 0 rows affected (0.00 sec) mysql> begin;commit;
Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.01 sec) mysql> set gtid_next="AUTOMATIC";
Query OK, 0 rows affected (0.00 sec) mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
结果
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_Running: Yes
Slave_SQL_Running: No
Last_Error: Error 'Can't drop database 'test'; database doesn't exist' on query. Default database: 'test'. Query: 'drop database test' Retrieved_Gtid_Set: 988b8684-3e21-22e6-a801-24505689c77d:1-9
Executed_Gtid_Set: 988b8684-3e21-22e6-a801-24505689c77d:9
没起作用!这是什么问题?
再去查看主库上的binlog日志,查找drop database test相关的日志:
# at 151
#160630 1:55:19 server id 623306 end_log_pos 199 CRC32 0x5954bb4c GTID [commit=yes]
SET @@SESSION.GTID_NEXT= '988b8684-3e21-22e6-a801-24505689c77d:1'/*!*/;
# at 199
#160630 1:55:19 server id 623306 end_log_pos 284 CRC32 0x6db10369 Query thread_id=1 exec_time=0 error_code=0
SET TIMESTAMP=1467222919/*!*/;
SET @@session.pseudo_thread_id=1/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1073741824/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
SET @@session.character_set_client=83,@@session.collation_connection=83,@@session.collation_server=83/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
drop database test
/*!*/;
问题找到了,drop database test对应的事务号是1,而不是顺序显示的9,接下来就简单了,重复上面的操作,但把事务号9改成1:
mysql> stop slave;
Query OK, 0 rows affected (0.00 sec) mysql> set gtid_next="988b8684-3e21-22e6-a801-24505689c77d:1";
Query OK, 0 rows affected (0.00 sec) mysql> begin;commit;
Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.01 sec) mysql> set gtid_next="AUTOMATIC";
Query OK, 0 rows affected (0.00 sec) mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
再有相似的报错也同样处理,最后终于没问题了:
mysql> show slave status\G
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Retrieved_Gtid_Set: 988b8684-3e21-22e6-a801-24505689c77d:1-9
Executed_Gtid_Set: 988b8684-3e21-22e6-a801-24505689c77d:1-9
over
收获:知其然很重要,知其所以然更重要
要理解GTID代表的是什么,每个事务的提交都代表着一个GTID的生成,正如其全名:全局事务ID(global transaction identifier),所以如果想跳过导致错误的事务不执行的话,需要找到对应事务的gtid号,设置(set gtid_next="....")并提交空事务后重新启用自动模式后,再重启slave就可以,并不是每个导致错误的事务都是binlog中最后一个事务
另外,还要理解相关的参数:
Retrieved_Gtid_Set
The set of global transaction IDs corresponding to all transactions received by this slave. Empty if GTIDs are not in use.
This is the set of all GTIDs that exist or have existed in the relay logs 即IO线程接收到的日志
Executed_Gtid_Set
The set of global transaction IDs written in the binary log. This is the same as the value for the global gtid_executed system variable on this server, as well as the value for Executed_Gtid_Set in the output of SHOW MASTER STATUS on this server. Empty if GTIDs are not in use. 即SQL线程执行到的位置
理解了这个后就能明白,之前的处理还是太复杂,其实直接看show slave satus\G的结果,看这两个参数的值:
Slave_IO_Running: Yes
Slave_SQL_Running: No
Last_Error: Error 'Can't drop database 'test'; database doesn't exist' on query. Default database: 'test'. Query: 'drop database test'
Retrieved_Gtid_Set: 988b8684-3e21-22e6-a801-24505689c77d:1-9
Executed_Gtid_Set:
能够看到,Executed_Gtid_Set是空的,而且GTID是肯定开启了的,所以,说明日志传过来后压根还没开始执行,所以,第一个事务就已经被卡住了,首先应该跳过的事务号就是1,也不必再去看日志了
查资料过程中看到一个很好的GTID介绍文章,链接在此:http://mysqllover.com/?p=594
GTID复制报错处理:Last_Error: Error 'Can't drop database 'test'; database doesn't exist' on query的更多相关文章
- mysql5.7同步复制报错1060故障处理
mysql5.7同步复制报错故障处理 # 报错 1060,具体如下Last_Errno: 1060Last_Error: Coordinator stopped because there were ...
- 解决FPDF报错:FPDF error: Not a JPEG file / FPDF error: Not a PNG file
最近有个项目需要用到FPDF,但是输出的时候报错: FPDF error: Not a JPEG file: http://***/data/attachment/forum/201603/19/10 ...
- VS经常报错的link error 2019
VS经常报错的link error 2019 原因如下: 可能是找得到头文件,但是相关的dll或者lib找不到,需要在配置里面添加相应的库文件. project=>configuration.. ...
- http报错之return error code:401 unauthorized
http报错之return error code:401 unauthorized 依据HTTP返回码所表示的意思应该是未授权,没有输入账号和password,因此解决方法就直接在HTTP包里面 ...
- Heka 编译安装后 运行报错 panic: runtime error: cgo argument has Go pointer to Go pointer
Heka 编译安装后 运行报错 panic: runtime error: cgo argument has Go pointer to Go pointer 解决办法: 1. Start heka ...
- PHP编译安装报错:configure: error: mcrypt.h not found. Please reinstall libmcrypt
我是在CentOS6.5安装php5.5.28这个版本,PHP编译代码如下: ./configure --prefix=/usr/local/php --with-config-file-path=/ ...
- mysql启动报错 mysql InnoDB: Error: could not open single-table tablespace file
mysql启动不成功,报错 mysql InnoDB: Error: could not open single-table tablespace file innodb_force_recovery ...
- xtrabackup备份MySQL报错:InnoDB: Error number 24 means 'Too many open files'
xtrabackup备份MySQL报错:InnoDB: Error number 24 means 'Too many open files' 1.使用xtrabackup备份MySQL时出现如下报错 ...
- Echarts 报错:Uncaught Error: [MODULE_MISS]"echarts/config" is not exists!
每天学习一点点 编程PDF电子书.视频教程免费下载:http://www.shitanlife.com/code 问题: 报错:Uncaught Error: [MODULE_MISS]" ...
随机推荐
- 使用WebRTC实现电脑与手机通过浏览器进行视频通话
最近一直在研究WebRTC,做了一个小项目:www.meet58.com,这个项目利用WebRTC.WebSocket可以让各种设备只通过浏览器进行视频聊天,无论是电脑.手机或者是平板.下面就是手机和 ...
- [转]轻量级 Java Web 框架架构设计
工作闲暇之余,我想设计并开发一款轻量级 Java Web 框架,看看能否取代目前最为流行的而又越来越重的 Spring.Hibernate 等框架.请原谅在下的大胆行为与不自量力,本人不是为了重造轮子 ...
- UIWindow & UIWindowLevel详解
一.UIWindow是一种特殊的UIView,通常在一个程序中只会有一个UIWindow,但可以手动创建多个UIWindow,同时加到程序里面.UIWindow在程序中主要起到三个作用: 1.作为容器 ...
- Spark配置&启动脚本分析
本文档基于Spark2.0,对spark启动脚本进行分析. date:2016/8/3 author:wangxl Spark配置&启动脚本分析 我们主要关注3类文件,配置文件,启动脚本文件以 ...
- codeforces 337C Quiz(贪心)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Quiz Manao is taking part in a quiz. The ...
- 飘逸的python - 多条件排序及itemgetter的应用
曾经客户端的同事用as写一大堆代码来排序,在得知python排序往往只需要一行,惊讶无比,遂对python产生浓厚的兴趣. 之前在做足球的积分榜的时候需要用到多条件排序,如果积分相同,则按净胜球,再相 ...
- spring2.5IOC控制反转详解
spring2.5IOC控制反转详解 19. 五 / J2EE / 一条评论 基本的代码结构 1 IOC包下 基本的spring创建对象 将类添加到配置文件中,由容器创建. Source code ...
- Js之Navigator对象
Window对象的navigator属性引用的是包含浏览器厂商和版本信息的Navigator对象.Navigator对象的命名是为了纪念Netscape之后NavigatorBU览器译注2,不过所有其 ...
- Struts2 - 常用的constant标签[转]
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-/ ...
- Spring连接MySQL、Oracle和SQL Server的数据库运动连接属性
在配置文件applicationContext.xml设置如下:<?xml version="1.0" encoding="UTF-8"?>< ...