mysql m-s via gtid
MySQL 创建 gtid主从
my.cnf中,在mysqld模块中加入如下的配置。(主库从库都这样)
# 修改server_id主库从库不一样
# on表示开启,OFF表示关闭
gtid-mode = ON
主库创建一个专用账号
grant replication slave on *.* to repl@"%" identified by "123456";
flush privileges;
从库指定master
CHANGE MASTER TO
MASTER_HOST='192.168.2.1',
MASTER_USER='repl',
MASTER_PASSWORD='123456',
MASTER_PORT=3306,
MASTER_AUTO_POSITION = 1;
启动slave:
stop slave;
start slave;
show slave status\G