标签:reset mysql-bin create mys worker dex root nbsp 红色
三台MySQL数据库做三主环形同步
同步策略:地主机从,机主仿从,仿主地从
地面关口:192.168.3.104
机载:192.168.3.101
信道仿真器:192.168.3.102
首先更改my.cnf文件:gedit etc/my.cnf
server_id = 3
log_bin = mysql-bin
binlog-do-db=link
#binlog-do-table=test.a
#slave_parallel_workers=4
relay-log=relay-bin
relay-log-index=relay-bin.index
replicate-do-db = link
replicate-do-table=link.sync
auto_increment_offset=3
auto_increment_increment=3
log-slave-updates=true
slave-skip-errors=all
红色字体最重要!
server_id 要不一样 三台数据库可以设为1、2、3
auto_increment_offset 同理 设为1、2、3
auto_increment_increment表示几台同步
log-slave-updates=true
slave-skip-errors=all
一定要加上!
第一步:在三台数据库里面设置权限账户
机载:create user ‘slave’@’192.168.3.102’ identified by ‘root’;
grant replication slave on . to ‘slave’@’192.168.3.102’;
地面:create user ‘slave’@’192.168.3.101’ identified by ‘root’;
grant replication slave on . to ‘slave’@’192.168.3.101’;
flush privileges;
信道仿真器:create user ‘slave’@’192.168.3.104’ identified by ‘root’;
grant replication slave on . to ‘slave’@’192.168.3.104’;
flush privileges;
第二步:查看log_file:show master status;
第三步:从机连接主机:
机载:change master to master_host=’192.168.3.104’,master_user=’slave’,master_password=’root’,master_log_file=’mysql-bin.000004’,master_log_pos=1113;
地面:change master to master_host=’192.168.3.102’,master_user=’slave’,master_password=’root’,master_log_file=’mysql-bin.000003’,master_log_pos=770;
信道仿真器:change master to master_host=’192.168.3.101’,master_user=’slave’,master_password=’root’,master_log_file=’mysql-bin.000001’,master_log_pos=662;
第四步:start slave;
第五步:查看连接状态:show slave status G;
Slave_io_running:yes
Slave_sql_running:yes
表示同步成功
停止同步:stop slave;
重置:reset slave;
标签:reset mysql-bin create mys worker dex root nbsp 红色
原文地址:https://www.cnblogs.com/lijianming180/p/12346610.html