MySQL 5.7 GTID复制到传统复制在线切换(3)

根据以上信息编写change master:
change master to master_auto_position=0,master_log_file='mysql-bin.000184',\
master_log_pos='475' for channel 'master-65303307';
start slave for channel 'master-65303307';

3.执行change master
change master to master_auto_position=0,master_log_file='mysql-bin.000435',\
master_log_pos=234 for channel 'master-65303306';
start slave for channel 'master-65303306';

change master to master_auto_position=0,master_log_file='mysql-bin.000184',\
master_log_pos=475 for channel 'master-65303307';
start slave for channel 'master-65303307';

4.更改日志格式(所有server)
set @@global.gtid_mode=on_permissive;
(product)root@localhost [test]> show variables like 'gtid_mode';
+---------------+---------------+
| Variable_name | Value        |
+---------------+---------------+
| gtid_mode    | ON_PERMISSIVE |
+---------------+---------------+
1 row in set (0.01 sec)

set @@global.gtid_mode=off_permissive;
(product)root@localhost [(none)]> show variables like 'gtid_mode';
+---------------+----------------+
| Variable_name | Value          |
+---------------+----------------+
| gtid_mode    | OFF_PERMISSIVE |
+---------------+----------------+
1 row in set (0.01 sec)

set @@global.gtid_mode=off;
(product)root@localhost [test]> show variables like 'gtid_mode';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| gtid_mode    | OFF  |
+---------------+-------+
1 row in set (0.01 sec)

5.验证更改
master1执行:
(product)root@localhost [mdb1]> insert into mdb1.t1 select 1;
查看slave channel 'master-65303306'的变化 :
插入数据前:
Relay_Master_Log_File: mysql-bin.000438
          Exec_Master_Log_Pos: 234
 Executed_Gtid_Set: 58abaa9b-73dd-11e6-9690-0050568a704b:1-16,
ebdca3fd-6eb7-11e6-b20c-0050568a704b:1-32459,
ebdca3fd-6eb7-11e6-b20c-0050568a704c:1-2
插入数据后:
Relay_Master_Log_File: mysql-bin.000438
          Exec_Master_Log_Pos: 539
 Executed_Gtid_Set: 58abaa9b-73dd-11e6-9690-0050568a704b:1-16,
ebdca3fd-6eb7-11e6-b20c-0050568a704b:1-32459,
ebdca3fd-6eb7-11e6-b20c-0050568a704c:1-2

master2执行:
(product)root@localhost [mdb2]> insert into mdb2.t2 select 1;
插入数据前:
Relay_Master_Log_File: mysql-bin.000187
          Exec_Master_Log_Pos: 194
            Executed_Gtid_Set: 58abaa9b-73dd-11e6-9690-0050568a704b:1-16,
ebdca3fd-6eb7-11e6-b20c-0050568a704b:1-32459,
ebdca3fd-6eb7-11e6-b20c-0050568a704c:1-2
插入数据后:
Relay_Master_Log_File: mysql-bin.000187
          Exec_Master_Log_Pos: 499
            Executed_Gtid_Set: 58abaa9b-73dd-11e6-9690-0050568a704b:1-16,
ebdca3fd-6eb7-11e6-b20c-0050568a704b:1-32459,
ebdca3fd-6eb7-11e6-b20c-0050568a704c:1-2

上面的GTID没有变化,只有pos位点有变化,说明已转换成传统复制生效。

6.更改配置文件
最后记得要更改my.cnf文件中的配置
gtid-mod=off
enforce-gtid-consistency=off

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/09f9acdd01880cb3bb37a7e4b40189ae.html