基本环境:PXC 5.7.19 Row+Gtid,3节点
一、Galera GTID vs MySQL GTID
1.1、Galera GTID vs MySQL GTID
Both kinds of GTIDs are using the same format: <source_id:trx_number>.
For Galera, <source_id> is generated when the cluster is bootstrapped. This <source_id> is shared by all nodes.
For MySQL, <source_id> is the server uuid. So it is easy to identify from which server a transaction originates.
我们先来看下PXC环境Galera GTID和MySQL GTID分别指的是什么
# node1的server_uuid mydba@192.168.85.132,3326 [replcrash]> select @@server_uuid; +--------------------------------------+ | @@server_uuid | +--------------------------------------+ | 31304898-67d8-11e8-bb20-000c29c1025c | +--------------------------------------+ 1 row in set (0.00 sec) # node1写入一条数据 mydba@192.168.85.132,3326 [replcrash]> insert into py_user(name,add_time,server_id) select left(uuid(),32),now(),@@server_id; Query OK, 1 row affected (0.02 sec) Records: 1 Duplicates: 0 Warnings: 0 # node1查看gtid_executed mydba@192.168.85.132,3326 [replcrash]> select @@global.gtid_executed; +----------------------------------------+ | @@global.gtid_executed | +----------------------------------------+ | 0f0f1664-9769-ee17-7834-ec71884d9f25:1 | +----------------------------------------+ 1 row in set (0.00 sec) # node2的server_uuid mydba@192.168.85.133,3326 [replcrash]> select @@server_uuid; +--------------------------------------+ | @@server_uuid | +--------------------------------------+ | 570e2242-6898-11e8-bcae-000c2900c99c | +--------------------------------------+ 1 row in set (0.01 sec) # node2写入一条数据 mydba@192.168.85.133,3326 [replcrash]> insert into py_user(name,add_time,server_id) select left(uuid(),32),now(),@@server_id; Query OK, 1 row affected (0.45 sec) Records: 1 Duplicates: 0 Warnings: 0 # node2查看gtid_executed mydba@192.168.85.133,3326 [replcrash]> select @@global.gtid_executed; +------------------------------------------+ | @@global.gtid_executed | +------------------------------------------+ | 0f0f1664-9769-ee17-7834-ec71884d9f25:1-2 | +------------------------------------------+ 1 row in set (0.00 sec)