mysql> set global gtid_mode='OFF_PERMISSIVE';
Query OK, 0 rows affected (0.01 sec)
mysql> set global gtid_mode='ON_PERMISSIVE';
Query OK, 0 rows affected (0.01 sec)
mysql> set global enforce_gtid_consistency=ON;
Query OK, 0 rows affected (0.00 sec)
mysql> set global gtid_mode='ON';
Query OK, 0 rows affected (0.00 sec)
②主库插数从库执行
mysql> show master status;
+------------------+----------+--------------+------------------+----------------------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+----------------------------------------+
| mysql-bin.000005 | 154 | | | 82b160c7-9a8f-11e6-8412-000c29c6361d:1 |
+------------------+----------+--------------+------------------+----------------------------------------+
1 row in set (0.00 sec)
可以看到gtid_set下面有数了,这说明已经开启了gtid模式
Part3:GTID变更为传统模式
mysql> stop slave;-----从库执行
Query OK, 0 rows affected (0.00 sec)
mysql> set global gtid_mode='ON_PERMISSIVE';
Query OK, 0 rows affected (0.00 sec)
mysql> set global gtid_mode='OFF_PERMISSIVE';
Query OK, 0 rows affected (0.01 sec)
mysql> CHANGE MASTER TO MASTER_AUTO_POSITION=0;
Query OK, 0 rows affected (0.05 sec)
mysql> set global gtid_mode='OFF';
Query OK, 0 rows affected (0.00 sec)
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like '%gtid%';
+----------------------------------+----------------------------------------+
| Variable_name | Value |
+----------------------------------+----------------------------------------+
| binlog_gtid_simple_recovery | ON |
| enforce_gtid_consistency | ON |
| gtid_executed_compression_period | 1000 |
| gtid_mode | OFF |
| gtid_next | AUTOMATIC |
| gtid_owned | |
| gtid_purged | 82b160c7-9a8f-11e6-8412-000c29c6361d:1 |
| session_track_gtids | OFF |
+----------------------------------+----------------------------------------+
8 rows in set (0.01 sec)
可以看到这里GTID模式已经关了,下面再次开启GTID模式来观察id的变化