mysql5.7使用gtid复制

概述

系统centos 7,mysql 5.7.14,安装省略


主库配置,增加参数

gtid-mode = on
enforce-gtid-consistency = 1
log-bin = /opt/mysql5.7/binlog
server-id = 3306100
binlog_format = row
skip_slave_start=1

在主库创建复制用户

GRANT REPLICATION SLAVE ON *.* TO repluser@192.168.1.203 IDENTIFIED BY 'replpassword';

flush privileges;

从库配置,增加参数

gtid-mode = on
enforce-gtid-consistency = 1 
log-bin =/opt/mysql5.7/binlog 
server-id = 3306101
binlog_format = row 
skip_slave_start=1


设置slave

CHANGE MASTER TO MASTER_HOST='192.168.1.202', MASTER_USER='repluser', MASTER_PASSWORD='replpassword', MASTER_AUTO_POSITION=1;

 start slave;

注意:

如果在安装mysql时,直接复制主库mysql作为从库mysql需要将从库的mysql的server_uuid修改,否则在复制时会出现

Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work.

解决:

在data存放目录中auto.conf中修改即可






展开阅读全文

没有更多推荐了,返回首页