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]" ...
随机推荐
- [Regex Expression] Confirmative -- World bundry
String to check: As it turns out, our potential shipmates are extremely superstitious. As such, we d ...
- The account is locked
SQL> select * from v$version where rownum=1; BANNER --------------------------------------------- ...
- hdoj 1863 畅通工程 最小生成树---prime算法
题目: http://acm.hdu.edu.cn/showproblem.php?pid=1863 注意有可能出现无法生成树的情况. #include <iostream> #inclu ...
- [core java学习笔记][第六章接口与内部类]
接口域内部类 接口 描述类具有什么功能,不给出具体实现. 内部类 用于设计协作关系的类集合 代理 实现任意接口的对象. 6.1 接口 接口声明 public interface Comparable ...
- iOS获取网络时间与转换格式
[NSDate date]可以获取系统时间,但是会造成一个问题,用户可以自己修改手机系统时间,所以有时候需要用网络时间而不用系统时间.获取网络标准时间的方法: 1.先在需要的地方实现下面的代码,创 ...
- C#winform修改IP,dns
/// 将IP,DNS设置为自动获取 /// private void setDHCP() { string _doscmd = & ...
- 【转】研华Adam6060某段时间后无法连接的问题
配合乙方测试,需连接现场Adam模块.一段时间后发现模块无法连接,网上资料甚少,发现此贴,记录下.以前没有多客户端高频次(其实谈不上高)连接,没有考虑连接释放的问题.另外,官方Demo也没有释放连接. ...
- Struts2学习笔记 国际化(Internationalization)
概述 国际化(Internationalization),通途的讲,就是让软件实现对多种语言的支持.可以通过简单的设置就可以从一种语言切换到另一种语言.用的最多的地方就是在应用程序的界面表示上.我们经 ...
- activiti笔记三 Activiti问题重现
测试的时候出现一个异常: ContextLoader.initWebApplicationContext(308) | Context initialization failed org.spring ...
- [C++程序设计]对“&”和“*”运算符
对“&”和“*”运算符再做些说明:(1) 如果已执行了“pointer_1=&a;”语句,请问&*pointer_1的含义是什么?“&”和“*”两个运算符的优先级别相同 ...