background image
MySQL5.7 在线开启/关闭 GTID
环境介绍
Part1:写在最前
截止本文撰写当日,MySQL5.7.16 是官网的最新稳定版,本文将用 MySQL5.7.16 来进行演示。
从 MySQL5.6 开始,支持了 GTID 复制模式,这种模式其实是把双刃剑,虽然容易搭建主从复
制了,但使用不当,就容易出现一些错误,例如 error 1236。在 MySQL5.6 如果开启 GTID
模式,需要在 my.cnf 中加入以下几个参数:
①log-bin=mysql-bin
②binlog_format=row
③log_slave_updates=1
④gtid_mode=ON
⑤enforce_gtid_consistency=ON
Warning:警告
这里的一些参数不是动态参数,也就是需要重启 mysql 才能生效。
Part2:环境
1
2
3
4
5
6
7
8
9
10
11
12
13
[root@HE1 ~]# mysql -uroot -p
Enter
password
:
Welcome
to
the MySQL monitor.
Commands
end with
;
or
\g.
Your MySQL
connection
id
is
4
Server version: 5.7.16-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle
and
/
or
its affiliates.
All
rights re
served.
Oracle
is
a registered trademark
of
Oracle Corporation
and
/
or
its
affiliates. Other names may be trademarks
of
their respective
owners.