配置master1
进入master1的etc/my.cnf
#开启binlog日期
log_bin=mysql-bin
server-id=1
## 同步日志
sync-binlog=1
## 忽略一些库
binlog-ignore-db=performance_schema
binlog-ignore-db=informance_schema
binlog-ignore-db=sys
## 同步一些表
binlog-do-db=xxx(表名)
## relay_log功能
relay_log=mysql-relay-bin
##从服务日志更新
log_slave_updates=1
##1.3.5.7.9
##指定自动递增
auto_increment_offset=1
##增量
auto_increment_increment=2
重启mysql
systemctl restart mysqld
进入mysql,查询,指定授权(授权过,直接取消)
show master status
## 授权
GRANT REPLICATION SLAVE ON *.* TO 'root'@'%' identified by 'root';
GRANT all privileges ON *.* TO 'root'@'%' identified by 'root';
##刷新
flush privileges;
配置master2
进入master2的etc/my.cnf
#开启binlog日期
log_bin=mysql-bin
server-id=3
## 同步日志
sync-binlog=1
## 忽略一些库
binlog-ignore-db=performance_schema
binlog-ignore-db=informance_schema
binlog-ignore-db=sys
## relay_log功能
relay_log=mysql-relay-bin
##从服务日志更新
log_slave_updates=1
##2,4,6,8,10
##指定自动递增
auto_increment_offset=2
##增量
auto_increment_increment=2
重启mysql
systemctl restart mysqld
授权
## 授权
GRANT REPLICATION SLAVE ON *.* TO 'root'@'%' identified by 'root';
GRANT all privileges ON *.* TO 'root'@'%' identified by 'root';
## 刷新
flush privileges;
查询状态
show master status
指定复制操作
master1指定master2(fileID,Position)
change master to master_host='59.151.15.36',master_port='3306',master_user='root',master_password='root',master_log_file=' mysql-bin.000016 ',master_log_pos=107;
## 启动slave
start slave;
## 查询状态
show slave status\G
master2指定master1(fileID,Position)
change master to master_host='59.151.15.36',master_port='3306',master_user='root',master_password='root',master_log_file=' mysql-bin.000016 ',master_log_pos=107;
## 启动slave
start slave;
## 查询状态
show slave status\G