[关闭]
@zhangyy 2021-10-26T14:32:57.000000Z 字数 4337 阅读 132

MySQL的MGR 安装多主模式部署

MySQL系列



一:MySQL 的MGR 集群部署

1.1 系统环境初始化

  1. 系统:CentOS7.9x64
  2. cat /etc/hosts
  3. -----
  4. 192.168.100.11 node01.flyfish.com
  5. 192.168.100.12 node02.flyfish.com
  6. 192.168.100.13 node03.flyfish.com
  7. 192.168.100.14 node04.flyfish.com
  8. 192.168.100.15 node05.flyfish.com
  9. 192.168.100.16 node06.flyfish.com
  10. 192.168.100.17 node07.flyfish.com
  11. 192.168.100.18 node08.flyfish.com
  12. 192.168.100.19 node09.flyfish.com
  13. ------
  14. 本次安装前3三台,并安装好MySQL5.7.36

1.2 MySQL group Replication 多主模式项目实施

  1. 01.配置参数:
  2. vi /mysql/data/3306/my.cnf
  3. 先注释掉:
  4. #bind-address = 0.0.0.0 (所有机器)
  5. ----
  6. #### log_bin 参数####
  7. log_bin=/mysql/log/3306/binlog/itpuxdb-binlog
  8. log_bin_index=/mysql/log/3306/binlog/itpuxdb-binlog.index
  9. binlog_format=row
  10. binlog_rows_query_log_events=on
  11. binlog_checksum=none
  12. slave-parallel-type=LOGICAL_CLOCK
  13. slave-parallel-workers=4
  14. slave_preserve_commit_order=1
  15. #### 打开GTID
  16. gtid_mode = on
  17. enforce_gtid_consistency = 1
  18. log-slave-updates = 1
  19. binlog_gtid_simple_recovery=1
  20. relay_log = /mysql/log/3306/relaylog/itpuxdb-relay.log
  21. relay-log-index = /mysql/log/3306/relaylog/itpuxdb-relay.index master_info_repository=table
  22. relay_log_info_repository=table
  23. ##MGR
  24. plugin_load="group_replication=group_replication.so"
  25. transaction_write_set_extraction=XXHASH64
  26. loose-group_replication_group_name="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
  27. loose-group_replication_start_on_boot=off
  28. loose-group_replication_local_address= "192.168.100.11:33006" ### 这个地方不一样填写本地地址端口
  29. loose-group_replication_group_seeds= "192.168.100.11:33006,192.168.100.12:33006,192.168.100.13:33006"
  30. loose-group_replication_bootstrap_group= off
  31. group_replication_single_primary_mode=off
  32. group_replication_enforce_update_everywhere_checks=on
  33. -----
  34. 从启MySQL
  35. systemctl restart mysqld
  1. 关于参数备注:

image_1fitf9pv0p7r10uk1vqdau81hhc9.png-2439.9kB

image_1fitfdtemntf1br5pdh6n1apgm.png-473.8kB

image_1fitie6a9kos1et671h1dle6k513.png-47.7kB

  1. 02. 配置第一台机器:(192.168.100.11
  2. ### 配置所用授权用户
  3. mysql -uroot -proot
  4. set sql_log_bin=0;
  5. create user repuser@'%' identified by 'repuser123';
  6. grant replication slave,replication client on *.* to repuser@'%';
  7. create user repuser@'127.0.0.1' identified by 'repuser123';
  8. grant replication slave,replication client on *.* to repuser@'127.0.0.1';
  9. create user repuser@'localhost' identified by 'repuser123';
  10. grant replication slave,replication client on *.* to repuser@'localhost';
  11. set sql_log_bin=1;

image_1fitif4e31bt11lh79c017ioqke1g.png-202kB

  1. ### 配置所用的用户复制通道:
  2. change master to master_user='repuser', master_password='repuser123' for channel 'group_replication_recovery';
  3. -- install plugin group_replication soname 'group_replication.so';
  4. show plugins;

image_1fitikg5bokg1vst980sm07os1t.png-154.1kB

  1. 建个复制群:
  2. set global group_replication_bootstrap_group=on;
  3. start group_replication;
  4. set global group_replication_bootstrap_group=off;
  5. select * from performance_schema.replication_group_members;

image_1fitj4q4911tt6ruqbsgmo1pek2q.png-147.2kB


  1. 配置第二台机器:(192.168.100.12
  2. mysql -uroot -proot
  3. set sql_log_bin=0;
  4. create user repuser@'%' identified by 'repuser123';
  5. grant replication slave,replication client on *.* to repuser@'%';
  6. create user repuser@'127.0.0.1' identified by 'repuser123';
  7. grant replication slave,replication client on *.* to repuser@'127.0.0.1';
  8. create user repuser@'localhost' identified by 'repuser123';
  9. grant replication slave,replication client on *.* to repuser@'localhost';
  10. set sql_log_bin=1;

image_1fitj8lg4kerrqk1p4si0mf2o37.png-149.8kB

  1. change master to master_user='repuser', master_password='repuser123' for channel 'group_replication_recovery';
  2. -- install plugin group_replication soname 'group_replication.so';
  3. show plugins;

image_1fitjd4al1ods1mjg58t281rcb44.png-136.3kB

  1. start group_replication;
  2. select * from performance_schema.replication_group_members;

image_1fitje9r35mo20g1n98fuk1q2t4h.png-97.9kB


  1. 其他节点:
  2. mysql -uroot -proot
  3. set sql_log_bin=0;
  4. create user repuser@'%' identified by 'repuser123';
  5. grant replication slave,replication client on *.* to repuser@'%';
  6. create user repuser@'127.0.0.1' identified by 'repuser123';
  7. grant replication slave,replication client on *.* to repuser@'127.0.0.1';
  8. create user repuser@'localhost' identified by 'repuser123';
  9. grant replication slave,replication client on *.* to repuser@'localhost';
  10. set sql_log_bin=1;

image_1fitjfnor1ok52nme061econlo4u.png-108.4kB

  1. change master to master_user='repuser', master_password='repuser123' for channel 'group_replication_recovery';
  2. -- install plugin group_replication soname 'group_replication.so';
  3. show plugins;

image_1fitjhrh1h6r1f9s1ilp1pcdq2r5b.png-133.4kB

  1. start group_replication;
  2. select * from performance_schema.replication_group_members;

image_1fitjjjko80p1lsf25kc56jdo68.png-125.6kB

  1. create database itpuxdb2;
  2. use itpuxdb2;
  3. create table itpuxdb2.itpuxbak11 (id int primary key ,name varchar(40)); insert into itpuxdb2.itpuxbak11 values (1,'itpux111'),(2,'itpux112'),(3,'itpux113'),(4,'itpux114'),(5,'itpux115');
  4. commit;
  5. select * from itpuxdb2.itpuxbak11;
  6. insert into itpuxdb2.itpuxbak11 values (21,'itpux111'),(22,'itpux112'),(23,'itpux113'),(24,'itpux114'),(25,'i tpux115');
  7. commit;
  8. select * from itpuxdb2.itpuxbak11;
  9. insert into itpuxdb2.itpuxbak11 values (31,'itpux111'),(32,'itpux112'),(33,'itpux113'),(34,'itpux114'),(35,'i tpux115');
  10. commit;

image_1fitka0cvkrg1ks71p7l1nv44b36l.png-130.1kB

image_1fitkkqaq1s8i1le5gb5e54g3m7i.png-109kB

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注