mysql 5.7 disable GTID replication

mysql 5.7 disable GTID replication

mysql 5.7.6及以后版本支持在线disable GTID replication，所以你可以使用传统的方法或者在线方法 disable GTID replication

1. Execute the following on each slave, and if you using multi-source replication, do it for each channel and include the FOR CHANNEL channel clause:

STOP SLAVE [FOR CHANNEL 'channel'];
CHANGE MASTER TO MASTER_AUTO_POSITION = 0, MASTER_LOG_FILE = file, \
MASTER_LOG_POS = position [FOR CHANNEL 'channel'];
START SLAVE [FOR CHANNEL 'channel'];
##如果你使用了多源复制，那么为每个channel执行如上操作

2. On each server, execute:

SET @@GLOBAL.GTID_MODE = ON_PERMISSIVE;

3. On each server, execute:

SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;

4. On each server, wait until the variable @@GLOBAL.GTID_OWNED is equal to the empty string. This can be checked using:

SELECT @@GLOBAL.GTID_OWNED;

NOTE:
On a replication slave, it is theoretically possible that this is empty and then nonempty again. This is not a problem, it suffices that it is empty once

5. 备份

If you use binary logs for anything else than replication, for example to do point in time backup or restore: wait until you do not need the old binary logs having GTID transactions.

6. On each server, execute:

SET @@GLOBAL.GTID_MODE = OFF;

7. On each server, set gtid-mode=OFF in my.cnf.

在每个实例的配置文件中添加gtid-mode=OFF

8. 你也可以选择设置enforce_gtid_consistency为OFF

set global enforce_gtid_consistency=OFF(同时在配置文件中添加)