十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
4个基本函数
创新互联公司"三网合一"的企业建站思路。企业可建设拥有电脑版、微信版、手机版的企业网站。实现跨屏营销,产品发布一步更新,电脑网络+移动网络一网打尽,满足企业的营销需求!创新互联公司具备承接各种类型的网站制作、成都网站制作项目的能力。经过10多年的努力的开拓,为不同行业的企事业单位提供了优质的服务,并获得了客户的一致好评。
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未执行。