Introduction
La fonction de réplication de MySQL version 5.7.17 a inauguré une nouvelle fonctionnalité, la fonction étoile brillante Réplication de groupe. Naturellement, il est indispensable d'avoir une certaine expérience en matière de construction et de tests, mais lors du processus de construction, nous avons rencontré des pièges liés au nom d'hôte. Ce qui suit expliquera comment le construire et le processus pour rencontrer cet écueil.
2
Attendez-vous
à créer deux instances 3306 et 3307 sur la machine virtuelle 192.168.56.102 et une instance 3308 sur 192.168.56.105. Selon les caractéristiques, vous devez sélectionner un nœud comme nœud pour démarrer la réplication de groupe. Cet article sélectionne 3306 comme nœud de démarrage.
3
Construire
instance 192.168.56.102:3306
mon contenu clé.cnf :
[mysqld3306] gtid-mode=on enforce-gtid-consistency=on master-info-repository=table relay-log-info-repository=table binlog-checksum=none log-slave-updates=on binlog-format=row transaction_write_set_extraction=XXHASH64 loose-group_replication_group_name="2dc52aec-cfea-11e6-95f3-080027264cfa" loose-group_replication_start_on_boot=off # 开机启动OFF loose-group_replication_local_address="192.168.56.102:33061" loose-group_replication_group_seeds="192.168.56.102:33061,192.168.56.102:33071,192.168.56.105:33081" loose-group_replication_bootstrap_group=off # 作为首个启动OFF
Remarque :
1. Les ports répertoriés dans la configuration sont requis et non utilisés.
2. Le format de group_name est UUID, vous pouvez exécuter select uuid();
Créer un compte de copie :
mysql> set sql_log_bin=0; mysql> create user 'group_repl'@'%' identified by 'group_repl'; mysql> grant replication slave on *.* to 'group_repl'@'%'; mysql> flush privileges; mysql> set sql_log_bin=1;
Créer une chaîne de copie :
mysql> change master to master_user='group_repl',master_password='group_repl' for channel 'group_replication_recovery';
Charger le plugin :
mysql> install plugin group_replication soname 'group_replication.so';
Démarrer la réplication de groupe en tant que premier nœud :
mysql> set @@global.group_replication_bootstrap_group=1; mysql> start group_replication; mysql> set @@global.group_replication_bootstrap_group=0; mysql> select * from performance_schema.replication_group_members\G *************************** 1. row *************************** CHANNEL_NAME: group_replication_applier MEMBER_ID: 4f987d01-cff0-11e6-9afa-080027264cfa MEMBER_HOST: localhost MEMBER_PORT: 3306 MEMBER_STATE: ONLINE
Instances 192.168.56.102:3307 et 192.168.56.105:3308
La plupart des opérations des instances restantes sont les mêmes que 102:3306. Seules les différentes parties sont listées ci-dessous :
1 Dans my.cnf, les paramètres de 102:3307 : <. 🎜>
loose-group_replication_local_address="192.168.56.102:33071",105:3308的参数:loose-group_replication_local_address="192.168.56.105:33081";
mysql> select * from performance_schema.replication_group_members\G *************************** 1. row *************************** CHANNEL_NAME: group_replication_applier MEMBER_ID: 4f987d01-cff0-11e6-9afa-080027264cfa MEMBER_HOST: localhost MEMBER_PORT: 3306 MEMBER_STATE: ONLINE *************************** 2. row *************************** CHANNEL_NAME: group_replication_applier MEMBER_ID: d8f7405d-cff1-11e6-b449-080027264cfa MEMBER_HOST: localhost MEMBER_PORT: 3307 MEMBER_STATE: ONLINE
.
mysql> select * from performance_schema.replication_group_members; *************************** 1. row *************************** CHANNEL_NAME: group_replication_applier MEMBER_ID: 4f987d01-cff0-11e6-9afa-080027264cfa MEMBER_HOST: localhost MEMBER_PORT: 3306 MEMBER_STATE: ONLINE *************************** 2. row *************************** CHANNEL_NAME: group_replication_applier MEMBER_ID: 645aef9a-d000-11e6-a756-080027d54077 MEMBER_HOST: localhost MEMBER_PORT: 3308 MEMBER_STATE: RECOVERING *************************** 3. row *************************** CHANNEL_NAME: group_replication_applier MEMBER_ID: d8f7405d-cff1-11e6-b449-080027264cfa MEMBER_HOST: localhost MEMBER_PORT: 3307 MEMBER_STATE: ONLINE
... 2017-01-02T17:35:02.123501Z 32 [Note] 'CHANGE MASTER TO FOR CHANNEL 'group_replication_recovery' executed'. Previous state master_host='<NULL>', master_port= 0, master_log_file='', master_log_pos= 4, master_bind=''. New state master_host='localhost', master_port= 3306, master_log_file='', master_log_pos= 4, master_bind=''. ... 2017-01-02T17:35:02.133661Z 34 [ERROR] Slave I/O for channel 'group_replication_recovery': error connecting to master 'group_repl@localhost:3306' - retry-time: 60 retries: 1, Error_code: 2003 ...
mysql> select * from performance_schema.replication_group_members\G *************************** 1. row *************************** CHANNEL_NAME: group_replication_applier MEMBER_ID: 4f987d01-cff0-11e6-9afa-080027264cfa MEMBER_HOST: 192.168.56.102 MEMBER_PORT: 3306 MEMBER_STATE: ONLINE *************************** 2. row *************************** CHANNEL_NAME: group_replication_applier MEMBER_ID: 645aef9a-d000-11e6-a756-080027d54077 MEMBER_HOST: 192.168.56.105 MEMBER_PORT: 3308 MEMBER_STATE: ONLINE *************************** 3. row *************************** CHANNEL_NAME: group_replication_applier MEMBER_ID: d8f7405d-cff1-11e6-b449-080027264cfa MEMBER_HOST: 192.168.56.102 MEMBER_PORT: 3307 MEMBER_STATE: ONLINE
mysql> select * from performance_schema.replication_group_members \G*************************** 1. row *************************** CHANNEL_NAME: group_replication_applier MEMBER_ID: 4f987d01-cff0-11e6-9afa-080027264cfa MEMBER_HOST: local-102 MEMBER_PORT: 3306 MEMBER_STATE: ONLINE *************************** 2. row *************************** CHANNEL_NAME: group_replication_applier MEMBER_ID: 645aef9a-d000-11e6-a756-080027d54077 MEMBER_HOST: local-105 MEMBER_PORT: 3308 MEMBER_STATE: ONLINE *************************** 3. row *************************** CHANNEL_NAME: group_replication_applier MEMBER_ID: d8f7405d-cff1-11e6-b449-080027264cfa MEMBER_HOST: local-102 MEMBER_PORT: 3307 MEMBER_STATE: ONLINE