MySQL5.7 集群搭建实例

在Vmware上搭建mysql5.7的docker实例,其配置如下:

主机 master slave
192.168.1.177 db36 db38
192.168.1.147 db16 db18

 

从资源上获取配置文件包。

该配置文件可以直接放置到目录下,使用docker-compose up -d启动使用。
其中server_id=XX不能重复

在master中执行:
grant replication slave,replication client on *.* to 'user1'@'%' identified by '1';
flush privileges;
show master status;
记录file和position,用在slave中的master_log_file和master_log_pos中。

例如:

+-----------------------+----------+--------------+------------------+-------------------+
| File                  | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-----------------------+----------+--------------+------------------+-------------------+
| demo-mysql-bin.000001 |      633 |              | mysql            |                   |
+-----------------------+----------+--------------+------------------+-------------------+

 

在slave中执行:
change master to master_host='192.168.1.147',master_user='user1',master_password='1',master_port=3336,master_log_file='demo-mysql-bin.000001',master_log_pos=633,master_connect_retry=30;
start slave;
show slave status\G;

 

主主同步:

db16和db36之间同步和上面master和slave过程一样,互相设置为主从就可以了。

 

 

 

 

 

 

 

你可能感兴趣的:(mysql)