4个基本函数1. GTID_SUBSET(set1,set2) - 若在set1中的GTID,也在set2中,返回true,否则返回false(set1是set2的子集)。[root@Mysql.sock]
4个基本函数
1. GTID_SUBSET(set1,set2) - 若在set1中的GTID,也在set2中,返回true,否则返回false(set1是set2的子集)。
[root@Mysql.sock][(none)]> SELECT GTID_SUBSET('3E11FA47-71CA-11E1-9E33-C80AA9429562:23','3E11FA47-71CA-11E1-9E33-C80AA9429562:21-57');
+-----------------------------------------------------------------------------------------------------+
| GTID_SUBSET('3E11FA47-71CA-11E1-9E33-C80AA9429562:23','3E11FA47-71CA-11E1-9E33-C80AA9429562:21-57') |
+-----------------------------------------------------------------------------------------------------+
| 1 |
+-----------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
[root@mysql.sock][(none)]> SELECT GTID_SUBSET('3E11FA47-71CA-11E1-9E33-C80AA9429562:20-25','3E11FA47-71CA-11E1-9E33-C80AA9429562:21-57');
+--------------------------------------------------------------------------------------------------------+
| GTID_SUBSET('3E11FA47-71CA-11E1-9E33-C80AA9429562:20-25','3E11FA47-71CA-11E1-9E33-C80AA9429562:21-57') |
+--------------------------------------------------------------------------------------------------------+
| 0 |
+--------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
2. GTID_SUBTRACT(set1,set2) - 返回在set1中,不在set2中的GTID集合(set1和set2的差集)。
[root@mysql.sock][(none)]> SELECT GTID_SUBTRACT('3E11FA47-71CA-11E1-9E33-C80AA9429562:21-57','3E11FA47-71CA-11E1-9E33-C80AA9429562:20-25');
+----------------------------------------------------------------------------------------------------------+
| GTID_SUBTRACT('3E11FA47-71CA-11E1-9E33-C80AA9429562:21-57','3E11FA47-71CA-11E1-9E33-C80AA9429562:20-25') |
+----------------------------------------------------------------------------------------------------------+
| 3e11fa47-71ca-11e1-9e33-c80aa9429562:26-57 |
+----------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)
[root@mysql.sock][(none)]> SELECT GTID_SUBTRACT('3E11FA47-71CA-11E1-9E33-C80AA9429562:21-57','3E11FA47-71CA-11E1-9E33-C80AA9429562:23-24');
+----------------------------------------------------------------------------------------------------------+
| GTID_SUBTRACT('3E11FA47-71CA-11E1-9E33-C80AA9429562:21-57','3E11FA47-71CA-11E1-9E33-C80AA9429562:23-24') |
+----------------------------------------------------------------------------------------------------------+
| 3e11fa47-71ca-11e1-9e33-c80aa9429562:21-22:25-57 |
+----------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
3. WAIT_FOR_EXECUTED_GTID_SET(gtid_set[, timeout]) - 等待gtid_set执行完,即GTID_SUBSET(gtid_subset, @@GLOBAL.gtid_executed)成立。timeout是可选的,超时参数。函数返回0,代表成功;返回1,代表超时;返回其它值,代表出错。
[root@mysql.sock][(none)]> SELECT WaiT_FOR_EXECUTED_GTID_SET('c4e5d4a0-a9be-11e9-b444-080027f22add:1-5',5);
+--------------------------------------------------------------------------+
| WAIT_FOR_EXECUTED_GTID_SET('c4e5d4a0-a9be-11e9-b444-080027f22add:1-5',5) |
+--------------------------------------------------------------------------+
| 0 |
+--------------------------------------------------------------------------+
1 row in set (0.00 sec)
4. WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS(gtid_set[, timeout][,channel]) - 和WAIT_FOR_EXECUTED_GTID_SET()类似,多了channel参数。
使用场景
1. 检查slave节点上是否执行了master上的所有GTIDs。
在salve节点上执行,SELECT GTID_SUBSET(master_gtid_executed, slave_gtid_executed),若返回0,说明slave节点上还有GTIDs未执行。
在slave节点上执行,SELECT GTID_SUBTRACT(master_gtid_executed, slave_gtid_executed),若返回GTIDs,也说明slave节点上还有GTIDs未执行。
--结束END--
本文标题: 说GTID - 与GTID相关的4个基本函数和使用场景
本文链接: https://lsjlt.com/news/38720.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0