#主服务器唯一Id
server-id=4
#启用二进制日志[必填]
#log-bin=自己mysql的路径/mysqlbin
#主机,0:读写,1:只读
read-only=0
#忽略不需要同步的数据库
#binlog-ignore-db=mysql
#需要同步的数据库:数据库名
binlog-do-db=test
#作为从库时 有写操作也要更新二进制文件
log_slave_updates
systemctl restart mysql
create user 'shuai'@'%' identified with mysql_native_password by 'shuai';
grant replication slave on *.* to 'shuai'@'%';
show master status

#主服务器唯一Id
server-id=3
#启用二进制日志[必填]
#log-bin=自己mysql的路径/mysqlbin
#主机,0:读写,1:只读
read-only=0
#忽略不需要同步的数据库
#binlog-ignore-db=mysql
#需要同步的数据库:数据库名
binlog-do-db=test
#作为从库时 有写操作也要更新二进制文件
log_slave_updates
systemctl restart mysql
create user 'shuai'@'%' identified with mysql_native_password by 'shuai';
grant replication slave on *.* to 'shuai'@'%';
show master status
=========================================================
#从服务器唯一Id
server-id=2
#主机,0:读写,1:只读
read-only=1
更新source_log_file、source_log_pos
change replication source to source_host='master4ip',source_port=3306,source_user='连接账号',source_password='连接账号密码',source_log_file='binlog.000019',source_log_pos=2589
start replica;
show replica status;

#从服务器唯一Id
server-id=1
#主机,0:读写,1:只读
read-only=1
更新source_log_file、source_log_pos
change replication source to source_host='master3ip',source_port=3306,source_user='连接账号',source_password='连接账号密码',source_log_file='binlog.000019',source_log_pos=2589
start replica;
show replica status;

=========================================================
更新source_log_file、source_log_pos
change replication source to source_host='master3ip',source_port=3306,source_user='shuai',source_password='shuai',source_log_file='binlog.000016',source_log_pos=156
更新source_log_file、source_log_pos
change replication source to source_host='master4ip',source_port=3306,source_user='shuai',source_password='shuai',source_log_file='binlog.000016',source_log_pos=156
start replica;
show replica status;
上一篇:Linux GCC 编译详解
下一篇:docker数据卷及软件部署方式