【docker】使用Docker快速体验MySQL半同步复制机制

2020-07-02  本文已影响0人  miniy_7
# 编辑
vi docker/mysql/master/conf/my.cnf
#内容
[mysqld]
binlog-format=ROW
log-bin=master-bin
log-slave-updates=true
gtid-mode=on
enforce-gtid-consistency=true
master-info-repository=TABLE
relay-log-info-repository=TABLE
sync-master-info=1
slave-parallel-workers=2
binlog-checksum=CRC32
master-verify-checksum=1
slave-sql-verify-checksum=1
binlog-rows-query-log_events=1
server-id=1
report-port=3306
report-host=master
plugin_load="rpl_semi_sync_master=semisync_master.so"
rpl_semi_sync_master_enabled=1
rpl_semi_sync_master_timeout=1000
# 编辑
vi docker/mysql/slave1/conf/my.cnf
#内容
[mysqld]
binlog-format=ROW
log-bin=mysql-bin.log
log-slave-updates=true
gtid-mode=on
enforce-gtid-consistency=true
master-info-repository=TABLE
relay-log-info-repository=TABLE
sync-master-info=1
slave-parallel-workers=2
binlog-checksum=CRC32
master-verify-checksum=1
slave-sql-verify-checksum=1
binlog-rows-query-log_events=1
server-id=11
report-port=3306
report-host=slave1
plugin_load="rpl_semi_sync_slave=semisync_slave.so"
rpl_semi_sync_slave_enabled=1
# 编辑
vi docker/mysql/slave2/conf/my.cnf
#内容
[mysqld]
binlog-format=ROW
log-bin=mysql-bin.log
log-slave-updates=true
gtid-mode=on
enforce-gtid-consistency=true
master-info-repository=TABLE
relay-log-info-repository=TABLE
sync-master-info=1
slave-parallel-workers=2
binlog-checksum=CRC32
master-verify-checksum=1
slave-sql-verify-checksum=1
binlog-rows-query-log_events=1
server-id=12
report-port=3306
report-host=slave1
plugin_load="rpl_semi_sync_slave=semisync_slave.so"
rpl_semi_sync_slave_enabled=1
# 主
docker run  -itd -p 3306:3306 -v /docker/mysql/master/conf:/etc/mysql/ --name mysql-master -e MYSQL_ROOT_PASSWORD=123456  mysql
# 从1
docker run  -itd -p 3307:3306 -v /docker/mysql/slave1/conf:/etc/mysql/ --name mysql-slave1 -e MYSQL_ROOT_PASSWORD=123456  mysql
# 从2
docker run  -itd -p 3308:3306 -v /docker/mysql/slave2/conf:/etc/mysql/ --name mysql-slave2 -e MYSQL_ROOT_PASSWORD=123456  mysql
docker inspect --format '{{.NetworkSettings.IPAddress}}' master slave1 slave2
> CHANGE MASTER TO MASTER_HOST='172.17.0.100',MASTER_USER='slave',MASTER_PASSWORD='123456', MASTER_AUTO_POSITION=1;
> START SLAVE;
show slave status \G;

参考博文
https://cloud.tencent.com/developer/article/1338804
https://www.cnblogs.com/songwenjie/p/9371422.html

上一篇下一篇

猜你喜欢

热点阅读