errant-transactions
https://www.percona.com/blog/2015/12/02/gtid-failover-with-mysqlslavetrx-fix-errant-transactions/
使用GTID复制时,Errant transactions是一个主要问题。 虽然这不是什么新鲜事,但GTID的缺点比常规复制更为臭名昭着。
错误的事务让您感到困难的是一个常见的DBA任务:故障转移。 现在像MHA这样的工具已经支持GTID复制(从0.56版本开始),这个协议变得越来越流行了,错误事务也是如此。 幸运的是,修复就像向空缺事务的数据库注入一个空的事务一样简单。 您可以轻松地通过master做到这一点,它会传播给所有的slaves。
我们来考虑以下情况:
当master吹到空中并且不在画面中时会发生什么?
当不只有一个而是几十个错误的事务时会发生什么?
当你有大量的slaves时会发生什么?
事情开始变得更复杂一点。
第一种情况的附注:当你的master不在时,你怎么找到错误的事务? 那么,你不能。 在这种情况下,你应该检查你的slave和你以前的slave/即将成为master之间的错误事务。
让我们考虑替代品。 什么是每个单一的slave注入每个错误的事务空交易的解决方法是什么? MySQL实用程序mysqlslavetrx。 基本上,这个工具允许我们在一个步骤中跳过多个slave上的多个事务。
安装MySQL实用程序的一种方法是执行以下步骤:
- wget http://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-utilities-1.6.2.tar.gz
- tar -xvzf mysql-utilities-1.6.2.tar.gz
- cd mysql-utilities-1.6.2
- python ./setup.py build
- sudo python ./setup.py install
你准备好了
那么一些例子呢? 假设我们有一个GTID复制的主/从服务器,当前状态如下:
mysql> show master status;
+------------------+----------+--------------+------------------+------------------------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+------------------------------------------+
| mysql-bin.000002 | 530 | | | 66fbd3be-976e-11e5-a8fb-1256731a26b7:1-2 |
+------------------+----------+--------------+------------------+------------------------------------------+
1 row in set (0.00 sec)
mysql> show slave statusG
...
Executed_Gtid_Set: 66fbd3be-976e-11e5-a8fb-1256731a26b7:1-2
Auto_Position: 1
1 row in set (0.00 sec)
向新的模式添加混乱的slave:
...
Executed_Gtid_Set: 66fbd3be-976e-11e5-a8fb-1256731a26b7:1-2,
674a625e-976e-11e5-a8fb-125cab082fc3:1
Auto_Position: 1
1 row in set (0.00 sec)
+-----------+
| is_subset |
+-----------+
| 1 |
+-----------+
1 row in set (0.00 sec)
Retrieved_Gtid_SetQuery OK, 0 rows affected (0.00 sec)
mysql> begin;
Query OK, 0 rows affected (0.00 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> SET GTID_NEXT='AUTOMATIC';
Query OK, 0 rows affected (0.00 sec)
+------------------+----------+--------------+------------------+----------------------------------------------------------------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+----------------------------------------------------------------------------------+
| mysql-bin.000002 | 715 | | | 66fbd3be-976e-11e5-a8fb-1256731a26b7:1-2,
674a625e-976e-11e5-a8fb-125cab082fc3:1 |
+------------------+----------+--------------+------------------+----------------------------------------------------------------------------------+
1 row in set (0.00 sec)
What you need to know is:
- The slave’s IP address
- The GTID set
It will be simple to execute:
mysqlslavetrx --gtid-set=6aa9a742828411e5a09b12aac3869fc9:1 --verbose --slaves=user:password@172.16.1.143:3306,user:password@172.16.1.144
gtid-set 写 所有slave上select gtid_subtract 查出来的事务
详细的输出将看起来像这样:
# GTID set to be skipped for each server:
# - 172.16.1.143@3306: 6aa9a742828411e5a09b12aac3869fc9:1
# - 172.16.1.144@3306: 6aa9a742828411e5a09b12aac3869fc9:1 #
# Injecting empty transactions for '172.16.1.143:3306'...
# - 6aa9a742828411e5a09b12aac3869fc9:1
# Injecting empty transactions for '172.16.1.144:3306'...
# - 6aa9a742828411e5a09b12aac3869fc9:1 #
#...done.
#
你可以从任何地方(master或slave)运行mysqlslavetrx。 您只需确保用户名和密码是有效的,并具有设置gtid_next变量所需的SUPER权限。
总结:利用MySQL实用程序。 在这种特殊情况下,使用GTID复制时,mysqlslavetrx非常有用,并且您希望执行干净的故障转移。 它可以作为MHA故障切换的前置脚本(自0.56版本以来支持GTID)添加,也可以简单地用于维护主站和从站之间的一致性。
errant-transactions的更多相关文章
- LOCK TABLES和UNLOCK TABLES与Transactions的交互
LOCK TABLES对事务不安全,并且在试图锁定表之前隐式提交任何活动事务. UNLOCK TABLES只有在LOCK TABLES已经获取到表锁时,会隐式提交任何活动事务.对于下面的一组语句,UN ...
- The Myths about Transactions (ACID) and NoSQL
There has been widespread characterization of one of the major distinctions between NoSQL and tradit ...
- 事务使用中如何避免误用分布式事务(System.Transactions.TransactionScope)
1:本地事务DbTransaction和分布式事务TransactionScope的区别: 1.1:System.Data.Common.DbTransaction: 本地事务:这个没什么好说了,就是 ...
- java.lang.IllegalStateException: Not allowed to create transaction on shared EntityManager - use Spring transactions or EJB CMT instead
java.lang.IllegalStateException: Not allowed to create transaction on sharedEntityManager - use Spri ...
- Netsuite > Hierarchy of transactions in Inventory cost calculation
First in day worksheets + Purchase Transactions (Receipts, Bills, Adjustments, Assembly Builds) + Tr ...
- PCI Express(六) - Simple transactions
原文地址:http://www.fpga4fun.com/PCI-Express6.html Let's try to control LEDs from the PCI Express bus. X ...
- [转]ORACLE DBA TRANSACTIONS
本文转自:http://blog.sina.com.cn/s/blog_66f845010100qelf.html 一, Transaction control 默认Transaction 由修改数据 ...
- Why you shouldn't use Entity Framework with Transactions
Links EntityFramework This is a .net ORM Mapper Framework from Microsoft to help you talking with yo ...
- Working with Transactions (EF6 Onwards)
Data Developer Center > Learn > Entity Framework > Get Started > Working with Transactio ...
随机推荐
- javascript 继承的两种方式
js中继承可以分为两种:对象冒充和原型链方式 一.对象冒充包括三种:临时属性方式.call()及apply()方式1.临时属性方式 代码如下: function Person(name){ t ...
- include和application
include指令 语法:<%@ include file=”路径+文件名” %> 把指定的文件包含到当前jsp中. application(应用的全局变量) 实现用户之间的数据共享 常 ...
- Nodejs-cli 填坑记
真的是玩玩没想到,一个cli竟然坑了我这么久,想当年写Python命令行工具的时候,哪有这么麻烦?随随便便写几下,添加个批处理命令脚本就搞定了.怎么Nodejs写一个就这么不顺利呢? 吐槽归吐槽,当我 ...
- HAWQ取代传统数仓实践(十三)——事实表技术之周期快照
一.周期快照简介 周期快照事实表中的每行汇总了发生在某一标准周期,如一天.一周或一月的多个度量.其粒度是周期性的时间段,而不是单个事务.周期快照事实表通常包含许多数据的总计,因为任何与事实表时间范围一 ...
- laravel 中将DB::select 得到的内容转为数组
$sql = "select count(*) as num from api_log where uid='{$this->uid}'"; $ ...
- WPF XMAL获取元素的父元素,子元素
/// 获得指定元素的父元素 /// </summary> /// <typeparam name="T">指定页面元素</typeparam> ...
- Python学习-括号
python语言最常见的括号有三种,分别是:小括号( ).中括号[ ]和大括号也叫做花括号{ }.其作用也各不相同,分别用来代表不同的python基本内置数据类型. 1.python中的小括号( ): ...
- C# null和" "的区别
String str1 = null; str引用为空 String str2 = ""; str引用一个空串 也就是null没有分配空间,""分 ...
- 十七、python沉淀之路--三元表达式、列表解析
一.三元表达式 a = '骑车' res = '好天气' if a == '骑车' else '睡觉' print(res) 睡觉 解析:res = '好天气' if a == '骑车' ...
- 十三、python沉淀之路--文件操作
一.文件的读操作 例1 f = open('学习',encoding='utf-8') #首先要打开文件,不然直接读,是读不出来的 data = f.read() #read后的括号里不添加任何东西 ...