@zhangyy
2021-10-26T06:32:57.000000Z
字数 4337
阅读 408
MySQL系列
系统:CentOS7.9x64cat /etc/hosts-----192.168.100.11 node01.flyfish.com192.168.100.12 node02.flyfish.com192.168.100.13 node03.flyfish.com192.168.100.14 node04.flyfish.com192.168.100.15 node05.flyfish.com192.168.100.16 node06.flyfish.com192.168.100.17 node07.flyfish.com192.168.100.18 node08.flyfish.com192.168.100.19 node09.flyfish.com------本次安装前3三台,并安装好MySQL5.7.36
01.配置参数:vi /mysql/data/3306/my.cnf先注释掉:#bind-address = 0.0.0.0 (所有机器)----#### log_bin 参数####log_bin=/mysql/log/3306/binlog/itpuxdb-binloglog_bin_index=/mysql/log/3306/binlog/itpuxdb-binlog.indexbinlog_format=rowbinlog_rows_query_log_events=onbinlog_checksum=noneslave-parallel-type=LOGICAL_CLOCKslave-parallel-workers=4slave_preserve_commit_order=1#### 打开GTIDgtid_mode = onenforce_gtid_consistency = 1log-slave-updates = 1binlog_gtid_simple_recovery=1relay_log = /mysql/log/3306/relaylog/itpuxdb-relay.logrelay-log-index = /mysql/log/3306/relaylog/itpuxdb-relay.index master_info_repository=tablerelay_log_info_repository=table##MGRplugin_load="group_replication=group_replication.so"transaction_write_set_extraction=XXHASH64loose-group_replication_group_name="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"loose-group_replication_start_on_boot=offloose-group_replication_local_address= "192.168.100.11:33006" ### 这个地方不一样填写本地地址端口loose-group_replication_group_seeds= "192.168.100.11:33006,192.168.100.12:33006,192.168.100.13:33006"loose-group_replication_bootstrap_group= offgroup_replication_single_primary_mode=offgroup_replication_enforce_update_everywhere_checks=on-----从启MySQL:systemctl restart mysqld
关于参数备注:



02. 配置第一台机器:(192.168.100.11)### 配置所用授权用户mysql -uroot -prootset sql_log_bin=0;create user repuser@'%' identified by 'repuser123';grant replication slave,replication client on *.* to repuser@'%';create user repuser@'127.0.0.1' identified by 'repuser123';grant replication slave,replication client on *.* to repuser@'127.0.0.1';create user repuser@'localhost' identified by 'repuser123';grant replication slave,replication client on *.* to repuser@'localhost';set sql_log_bin=1;

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

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

配置第二台机器:(192.168.100.12)mysql -uroot -prootset sql_log_bin=0;create user repuser@'%' identified by 'repuser123';grant replication slave,replication client on *.* to repuser@'%';create user repuser@'127.0.0.1' identified by 'repuser123';grant replication slave,replication client on *.* to repuser@'127.0.0.1';create user repuser@'localhost' identified by 'repuser123';grant replication slave,replication client on *.* to repuser@'localhost';set sql_log_bin=1;

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

start group_replication;select * from performance_schema.replication_group_members;

其他节点:mysql -uroot -prootset sql_log_bin=0;create user repuser@'%' identified by 'repuser123';grant replication slave,replication client on *.* to repuser@'%';create user repuser@'127.0.0.1' identified by 'repuser123';grant replication slave,replication client on *.* to repuser@'127.0.0.1';create user repuser@'localhost' identified by 'repuser123';grant replication slave,replication client on *.* to repuser@'localhost';set sql_log_bin=1;

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

start group_replication;select * from performance_schema.replication_group_members;

create database itpuxdb2;use itpuxdb2;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');commit;select * from itpuxdb2.itpuxbak11;insert into itpuxdb2.itpuxbak11 values (21,'itpux111'),(22,'itpux112'),(23,'itpux113'),(24,'itpux114'),(25,'i tpux115');commit;select * from itpuxdb2.itpuxbak11;insert into itpuxdb2.itpuxbak11 values (31,'itpux111'),(32,'itpux112'),(33,'itpux113'),(34,'itpux114'),(35,'i tpux115');commit;

