您好,登录后才能下订单哦!
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未执行。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。