MySQL手记20 -- MySQL Group Replication(MGR组复制)
Posted 朔的话
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL手记20 -- MySQL Group Replication(MGR组复制)相关的知识,希望对你有一定的参考价值。
#gtid
gtid_mode=on
enforce_gtid_consistency=on
binlog_checksum=none
transaction_write_set_extraction = XXHASH64
loose-group_replication_group_name = "8cb61fd9-8931-11ea-ad6f-0242ac110003"
loose_group_replication_single_primary_mode = 0 #0:single-primary; 1:multiple-primary
loose-group_replication_start_on_boot = OFF
loose_group_replication_compression_threshold = 100
loose_group_replication_flow_control_mode = 0
loose-group_replication_bootstrap_group = OFF
loose_group_replication_enforce_update_everywhere_checks =true #single-primary需设为关闭,multiple-primary则必须打开,主要是使(serialized隔离级别的事务,或者是使事务中有外键关系的表的)事务失败
loose-group_replication_transaction_size_limit = 10485760 #事务的大小,若太大,则会影响集群的性能
loose_group_replication_unreachable_majority_timeout = 120
loose-group_replication_auto_increment_increment = 7 #自增值的跨度大小
loose-group_replication_local_address="172.21.0.2:15501" #当前主机的ip,可动态修改
loose-group_replication_group_seeds='172.21.0.2:15501,172.21.0.4:15503,172.21.0.3:15502' ##集群中所有节点的信息,可动态修改
loose_group_replication_ip_whitelist='172.21.0.4,172.21.0.2,172.21.0.3' #节点的ip白名单,可动态修改
mysql> INSTALL PLUGIN group_replication SONAME 'group_replication.so';
mysql> SHOW PLUGINS;
+---------------------------------+----------+--------------------+----------------------+---------+
| Name | Status | Type | Library | License |
+---------------------------------+----------+--------------------+----------------------+---------+
...
| group_replication | ACTIVE | GROUP REPLICATION | group_replication.so | GPL |
+---------------------------------+----------+--------------------+----------------------+---------+
SET GLOBAL group_replication_bootstrap_group=ON;
START GROUP_REPLICATION;
[System] [MY-010597] [Repl] 'CHANGE MASTER TO FOR CHANNEL 'group_replication_applier' executed'. Previous state master_host='<NULL>', master_port= 0, master_log_file='', master_log_pos= 4, master_bind=''. New state master_host='<NULL>', master_port= 0, master_log_file='', master_log_pos= 4, master_bind=''.
START GROUP_REPLICATION;
[System] [MY-010597] [Repl] 'CHANGE MASTER TO FOR CHANNEL 'group_replication_applier' executed'. Previous state master_host='<NULL>', master_port= 0, master_log_file='', master_log_pos= 4, master_bind=''. New state master_host='<NULL>', master_port= 0, master_log_file='', master_log_pos= 4, master_bind=''.
[System] [MY-010597] [Repl] '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='70b353672cdc', master_port= 5501, master_log_file='', master_log_pos= 4, master_bind=''.
[Warning] [MY-010897] [Repl] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
2020-05-22T07:34:16.119089-00:00 27 [System] [MY-010562] [Repl] Slave I/O thread for channel 'group_replication_recovery': connected to master 'root@70b353672cdc:5501',replication started in log 'FIRST' at position 4
[System] [MY-010597] [Repl] 'CHANGE MASTER TO FOR CHANNEL 'group_replication_recovery' executed'. Previous state master_host='70b353672cdc', master_port= 5501, master_log_file='', master_log_pos= 4, master_bind=''. New state master_host='<NULL>', master_port= 0, master_log_file='', master_log_pos= 4, master_bind=''.
mysql> select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+----------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION |
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+----------------+
| group_replication_applier | e3f0850e-8936-11ea-98ba-0242ac150004 | 2bd38a52527e | 5502 | ONLINE | PRIMARY | 8.0.20 |
| group_replication_applier | e4a14f46-8936-11ea-b379-0242ac150005 | 70b353672cdc | 5501 | ONLINE | PRIMARY | 8.0.20 |
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+----------------+
2 rows in set (0.00 sec)
mysql> select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+----------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION |
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+----------------+
| group_replication_applier | e3f0850e-8936-11ea-98ba-0242ac150004 | 2bd38a52527e | 5502 | RECOVERING | PRIMARY | 8.0.20 |
| group_replication_applier | e4a14f46-8936-11ea-b379-0242ac150005 | 70b353672cdc | 5501 | ONLINE | PRIMARY | 8.0.20 |
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+----------------+
2 rows in set (0.03 sec)
[Warning] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] Automatically adding IPv4 localhost address to the whitelist. It is mandatory that it is added.'
[Warning] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] Automatically adding IPv6 localhost address to the whitelist. It is mandatory that it is added.'
[System] [MY-010597] [Repl] 'CHANGE MASTER TO FOR CHANNEL 'group_replication_applier' executed'. Previous state master_host='<NULL>', master_port= 0, master_log_file='', master_log_pos= 4, master_bind=''. New state master_host='<NULL>', master_port= 0, master_log_file='', master_log_pos= 4, master_bind=''.
[System] [MY-010597] [Repl] '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='70b353672cdc', master_port= 5501, master_log_file='', master_log_pos= 4, master_bind=''.
[Warning] [MY-010897] [Repl] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
[System] [MY-010562] [Repl] Slave I/O thread for channel 'group_replication_recovery': connected to master 'root@70b353672cdc:5501',replication started in log 'FIRST' at position 4
[System] [MY-010597] [Repl] 'CHANGE MASTER TO FOR CHANNEL 'group_replication_recovery' executed'. Previous state master_host='70b353672cdc', master_port= 5501, master_log_file='', master_log_pos= 4, master_bind=''. New state master_host='<NULL>', master_port= 0, master_log_file='', master_log_pos= 4, master_bind=''.
mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+----------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION |
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+----------------+
| group_replication_applier | e0dd6e3d-8936-11ea-9176-0242ac150003 | 7bcecb1807d5 | 5503 | ONLINE | PRIMARY | 8.0.20 |
| group_replication_applier | e3f0850e-8936-11ea-98ba-0242ac150004 | 2bd38a52527e | 5502 | ONLINE | PRIMARY | 8.0.20 |
| group_replication_applier | e4a14f46-8936-11ea-b379-0242ac150005 | 70b353672cdc | 5501 | ONLINE | PRIMARY | 8.0.20 |
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+----------------+
3 rows in set (0.02 sec)
mysql> show variables like '%group_repl%';
+-----------------------------------------------------+----------------------------------------------------+
| Variable_name | Value |
+-----------------------------------------------------+----------------------------------------------------+
| group_replication_allow_local_lower_version_join | OFF |
| group_replication_auto_increment_increment | 7 |
| group_replication_autorejoin_tries | 0 |
| group_replication_bootstrap_group | OFF |
| group_replication_clone_threshold | 9223372036854775807 |
| group_replication_communication_debug_options | GCS_DEBUG_NONE |
| group_replication_communication_max_message_size | 10485760 |
| group_replication_components_stop_timeout | 31536000 |
| group_replication_compression_threshold | 100 |
| group_replication_consistency | EVENTUAL |
| group_replication_enforce_update_everywhere_checks | ON |
| group_replication_exit_state_action | READ_ONLY |
| group_replication_flow_control_applier_threshold | 25000 |
| group_replication_flow_control_certifier_threshold | 25000 |
| group_replication_flow_control_hold_percent | 10 |
| group_replication_flow_control_max_quota | 0 |
| group_replication_flow_control_member_quota_percent | 0 |
| group_replication_flow_control_min_quota | 0 |
| group_replication_flow_control_min_recovery_quota | 0 |
| group_replication_flow_control_mode | DISABLED |
| group_replication_flow_control_period | 1 |
| group_replication_flow_control_release_percent | 50 |
| group_replication_force_members | |
| group_replication_group_name | 8cb61fd9-8931-11ea-ad6f-0242ac110003 |
| group_replication_group_seeds | 172.21.0.2:15501,172.21.0.4:15503,172.21.0.3:15502 |
| group_replication_gtid_assignment_block_size | 1000000 |
| group_replication_ip_whitelist | 172.21.0.4,172.21.0.2,172.21.0.3,172.21.0.5 |
| group_replication_local_address | 172.21.0.3:15502 |
| group_replication_member_expel_timeout | 0 |
| group_replication_member_weight | 50 |
| group_replication_message_cache_size | 1073741824 |
| group_replication_poll_spin_loops | 0 |
| group_replication_recovery_complete_at | TRANSACTIONS_APPLIED |
| group_replication_recovery_compression_algorithms | uncompressed |
| group_replication_recovery_get_public_key | OFF |
| group_replication_recovery_public_key_path | |
| group_replication_recovery_reconnect_interval | 60 |
| group_replication_recovery_retry_count | 10 |
| group_replication_recovery_ssl_ca | |
| group_replication_recovery_ssl_capath | |
| group_replication_recovery_ssl_cert | |
| group_replication_recovery_ssl_cipher | |
| group_replication_recovery_ssl_crl | |
| group_replication_recovery_ssl_crlpath | |
| group_replication_recovery_ssl_key | |
| group_replication_recovery_ssl_verify_server_cert | OFF |
| group_replication_recovery_tls_ciphersuites | |
| group_replication_recovery_tls_version | TLSv1,TLSv1.1,TLSv1.2,TLSv1.3 |
| group_replication_recovery_use_ssl | OFF |
| group_replication_recovery_zstd_compression_level | 3 |
| group_replication_single_primary_mode | OFF |
| group_replication_ssl_mode | DISABLED |
| group_replication_start_on_boot | OFF |
| group_replication_transaction_size_limit | 10485760 |
| group_replication_unreachable_majority_timeout | 120 |
+-----------------------------------------------------+----------------------------------------------------+
55 rows in set (0.12 sec)
mysql> use performance_schema
Database changed
mysql> show tables like '%group%';
+----------------------------------------+
| Tables_in_performance_schema (%group%) |
+----------------------------------------+
| replication_group_member_stats |
| replication_group_members |
+----------------------------------------+
2 rows in set (0.00 sec)
mysql> select * from replication_group_members ;
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+----------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION |
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+----------------+
| group_replication_applier | e0dd6e3d-8936-11ea-9176-0242ac150003 | 7bcecb1807d5 | 5503 | ONLINE | PRIMARY | 8.0.20 |
| group_replication_applier | e3f0850e-8936-11ea-98ba-0242ac150004 | 2bd38a52527e | 5502 | ONLINE | PRIMARY | 8.0.20 |
| group_replication_applier | e4a14f46-8936-11ea-b379-0242ac150005 | 70b353672cdc | 5501 | ONLINE | PRIMARY | 8.0.20 |
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+----------------+
3 rows in set (0.01 sec)
mysql> show create table replication_group_member_stats \G
*************************** 1. row ***************************
Table: replication_group_member_stats
Create Table: CREATE TABLE `replication_group_member_stats` (
`CHANNEL_NAME` char(64) NOT NULL,
`VIEW_ID` char(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`MEMBER_ID` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`COUNT_TRANSACTIONS_IN_QUEUE` bigint unsigned NOT NULL,
`COUNT_TRANSACTIONS_CHECKED` bigint unsigned NOT NULL,
`COUNT_CONFLICTS_DETECTED` bigint unsigned NOT NULL,
`COUNT_TRANSACTIONS_ROWS_VALIDATING` bigint unsigned NOT NULL,
`TRANSACTIONS_COMMITTED_ALL_MEMBERS` longtext NOT NULL,
`LAST_CONFLICT_FREE_TRANSACTION` text NOT NULL,
`COUNT_TRANSACTIONS_REMOTE_IN_APPLIER_QUEUE` bigint unsigned NOT NULL,
`COUNT_TRANSACTIONS_REMOTE_APPLIED` bigint unsigned NOT NULL,
`COUNT_TRANSACTIONS_LOCAL_PROPOSED` bigint unsigned NOT NULL,
`COUNT_TRANSACTIONS_LOCAL_ROLLBACK` bigint unsigned NOT NULL
) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
mysql> select * from replication_group_member_stats;
+---------------------------+---------------------+--------------------------------------+-----------------------------+----------------------------+--------------------------+------------------------------------+---------------------------------------------------------------------------------------------------------------------+-----------------------------------------+--------------------------------------------+-----------------------------------+-----------------------------------+-----------------------------------+
| CHANNEL_NAME | VIEW_ID | MEMBER_ID | COUNT_TRANSACTIONS_IN_QUEUE | COUNT_TRANSACTIONS_CHECKED | COUNT_CONFLICTS_DETECTED | COUNT_TRANSACTIONS_ROWS_VALIDATING | TRANSACTIONS_COMMITTED_ALL_MEMBERS | LAST_CONFLICT_FREE_TRANSACTION | COUNT_TRANSACTIONS_REMOTE_IN_APPLIER_QUEUE | COUNT_TRANSACTIONS_REMOTE_APPLIED | COUNT_TRANSACTIONS_LOCAL_PROPOSED | COUNT_TRANSACTIONS_LOCAL_ROLLBACK |
+---------------------------+---------------------+--------------------------------------+-----------------------------+----------------------------+--------------------------+------------------------------------+---------------------------------------------------------------------------------------------------------------------+-----------------------------------------+--------------------------------------------+-----------------------------------+-----------------------------------+-----------------------------------+
| group_replication_applier | 15903747614426007:3 | e0dd6e3d-8936-11ea-9176-0242ac150003 | 0 | 167 | 0 | 1 | 8cb61fd9-8931-11ea-ad6f-0242ac110003:1-43:1000020-1000167:2000020-2000037,
e4a14f46-8936-11ea-b379-0242ac150005:1-5 | 8cb61fd9-8931-11ea-ad6f-0242ac110003:43 | 0 | 21 | 146 | 0 |
| group_replication_applier | 15903747614426007:3 | e3f0850e-8936-11ea-98ba-0242ac150004 | 0 | 167 | 0 | 1 | 8cb61fd9-8931-11ea-ad6f-0242ac110003:1-43:1000020-1000167:2000020-2000037,
e4a14f46-8936-11ea-b379-0242ac150005:1-5 | 8cb61fd9-8931-11ea-ad6f-0242ac110003:43 | 0 | 151 | 17 | 0 |
| group_replication_applier | 15903747614426007:3 | e4a14f46-8936-11ea-b379-0242ac150005 | 0 | 167 | 0 | 1 | 8cb61fd9-8931-11ea-ad6f-0242ac110003:1-43:1000020-1000167:2000020-2000037,
e4a14f46-8936-11ea-b379-0242ac150005:1-5 | 8cb61fd9-8931-11ea-ad6f-0242ac110003:43 | 0 | 166 | 4 | 0 |
+---------------------------+---------------------+--------------------------------------+-----------------------------+----------------------------+--------------------------+------------------------------------+---------------------------------------------------------------------------------------------------------------------+-----------------------------------------+--------------------------------------------+-----------------------------------+-----------------------------------+-----------------------------------+
3 rows in set (0.00 sec)
mysql> select CHANNEL_NAME,VIEW_ID,MEMBER_ID,TRANSACTIONS_COMMITTED_ALL_MEMBERS from replication_group_member_stats;
+---------------------------+---------------------+--------------------------------------+-------------------------------------------------------------------------------------------------------------+
| CHANNEL_NAME | VIEW_ID | MEMBER_ID | TRANSACTIONS_COMMITTED_ALL_MEMBERS |
+---------------------------+---------------------+--------------------------------------+-------------------------------------------------------------------------------------------------------------+
| group_replication_applier | 15903747614426007:3 | e0dd6e3d-8936-11ea-9176-0242ac150003 | 8cb61fd9-8931-11ea-ad6f-0242ac110003:1-39:1000020-1000021:2000020,
e4a14f46-8936-11ea-b379-0242ac150005:1-5 |
| group_replication_applier | 15903747614426007:3 | e3f0850e-8936-11ea-98ba-0242ac150004 | 8cb61fd9-8931-11ea-ad6f-0242ac110003:1-39:1000020-1000021:2000020,
e4a14f46-8936-11ea-b379-0242ac150005:1-5 |
| group_replication_applier | 15903747614426007:3 | e4a14f46-8936-11ea-b379-0242ac150005 | 8cb61fd9-8931-11ea-ad6f-0242ac110003:1-39:1000020-1000021:2000020,
e4a14f46-8936-11ea-b379-0242ac150005:1-5 |
+---------------------------+---------------------+--------------------------------------+-------------------------------------------------------------------------------------------------------------+
3 rows in set (0.00 sec)
mysql> select MEMBER_ID,COUNT_TRANSACTIONS_IN_QUEUE,COUNT_TRANSACTIONS_CHECKED,COUNT_CONFLICTS_DETECTED,COUNT_TRANSACTIONS_ROWS_VALIDATING,LAST_CONFLICT_FREE_TRANSACTION,COUNT_TRANSACTIONS_REMOTE_IN_APPLIER_QUEUE,COUNT_TRANSACTIONS_REMOTE_APPLIED,COUNT_TRANSACTIONS_LOCAL_PROPOSED,COUNT_TRANSACTIONS_LOCAL_ROLLBACK from replication_group_member_stats;
+--------------------------------------+-----------------------------+----------------------------+--------------------------+------------------------------------+----------------------------------------------+--------------------------------------------+-----------------------------------+-----------------------------------+-----------------------------------+
| MEMBER_ID | COUNT_TRANSACTIONS_IN_QUEUE | COUNT_TRANSACTIONS_CHECKED | COUNT_CONFLICTS_DETECTED | COUNT_TRANSACTIONS_ROWS_VALIDATING | LAST_CONFLICT_FREE_TRANSACTION | COUNT_TRANSACTIONS_REMOTE_IN_APPLIER_QUEUE | COUNT_TRANSACTIONS_REMOTE_APPLIED | COUNT_TRANSACTIONS_LOCAL_PROPOSED | COUNT_TRANSACTIONS_LOCAL_ROLLBACK |
+--------------------------------------+-----------------------------+----------------------------+--------------------------+------------------------------------+----------------------------------------------+--------------------------------------------+-----------------------------------+-----------------------------------+-----------------------------------+
| e0dd6e3d-8936-11ea-9176-0242ac150003 | 0 | 166 | 0 | 18 | 8cb61fd9-8931-11ea-ad6f-0242ac110003:2000037 | 0 | 20 | 146 | 0 |
| e3f0850e-8936-11ea-98ba-0242ac150004 | 0 | 166 | 0 | 18 | 8cb61fd9-8931-11ea-ad6f-0242ac110003:2000037 | 0 | 150 | 17 | 0 |
| e4a14f46-8936-11ea-b379-0242ac150005 | 0 | 166 | 0 | 18 | 8cb61fd9-8931-11ea-ad6f-0242ac110003:2000037 | 0 | 166 | 3 | 0 |
+--------------------------------------+-----------------------------+----------------------------+--------------------------+------------------------------------+----------------------------------------------+--------------------------------------------+-----------------------------------+-----------------------------------+-----------------------------------+
3 rows in set (0.01 sec)
mysql> insert into t2 values(6);
Query OK, 1 row affected (0.04 sec)
mysql> select MEMBER_ID,COUNT_TRANSACTIONS_IN_QUEUE,COUNT_TRANSACTIONS_CHECKED,COUNT_CONFLICTS_DETECTED,COUNT_TRANSACTIONS_ROWS_VALIDATING,LAST_CONFLICT_FREE_TRANSACTION,COUNT_TRANSACTIONS_REMOTE_IN_APPLIER_QUEUE,COUNT_TRANSACTIONS_REMOTE_APPLIED,COUNT_TRANSACTIONS_LOCAL_PROPOSED,COUNT_TRANSACTIONS_LOCAL_ROLLBACK from replication_group_member_stats;
+--------------------------------------+-----------------------------+----------------------------+--------------------------+------------------------------------+----------------------------------------------+--------------------------------------------+-----------------------------------+-----------------------------------+-----------------------------------+
| MEMBER_ID | COUNT_TRANSACTIONS_IN_QUEUE | COUNT_TRANSACTIONS_CHECKED | COUNT_CONFLICTS_DETECTED | COUNT_TRANSACTIONS_ROWS_VALIDATING | LAST_CONFLICT_FREE_TRANSACTION | COUNT_TRANSACTIONS_REMOTE_IN_APPLIER_QUEUE | COUNT_TRANSACTIONS_REMOTE_APPLIED | COUNT_TRANSACTIONS_LOCAL_PROPOSED | COUNT_TRANSACTIONS_LOCAL_ROLLBACK |
+--------------------------------------+-----------------------------+----------------------------+--------------------------+------------------------------------+----------------------------------------------+--------------------------------------------+-----------------------------------+-----------------------------------+-----------------------------------+
| e0dd6e3d-8936-11ea-9176-0242ac150003 | 0 | 167 | 0 | 19 | 8cb61fd9-8931-11ea-ad6f-0242ac110003:2000037 | 0 | 21 | 146 | 0 |
| e3f0850e-8936-11ea-98ba-0242ac150004 | 0 | 167 | 0 | 19 | 8cb61fd9-8931-11ea-ad6f-0242ac110003:43 | 0 | 151 | 17 | 0 |
| e4a14f46-8936-11ea-b379-0242ac150005 | 0 | 167 | 0 | 19 | 8cb61fd9-8931-11ea-ad6f-0242ac110003:2000037 | 0 | 166 | 4 | 0 |
+--------------------------------------+-----------------------------+----------------------------+--------------------------+------------------------------------+----------------------------------------------+--------------------------------------------+-----------------------------------+-----------------------------------+-----------------------------------+
3 rows in set (0.01 sec)
mysql> select MEMBER_ID,COUNT_TRANSACTIONS_IN_QUEUE,COUNT_TRANSACTIONS_CHECKED,COUNT_CONFLICTS_DETECTED,COUNT_TRANSACTIONS_ROWS_VALIDATING,LAST_CONFLICT_FREE_TRANSACTION,COUNT_TRANSACTIONS_REMOTE_IN_APPLIER_QUEUE,COUNT_TRANSACTIONS_REMOTE_APPLIED,COUNT_TRANSACTIONS_LOCAL_PROPOSED,COUNT_TRANSACTIONS_LOCAL_ROLLBACK from replication_group_member_stats;
+--------------------------------------+-----------------------------+----------------------------+--------------------------+------------------------------------+-----------------------------------------+--------------------------------------------+-----------------------------------+-----------------------------------+-----------------------------------+
| MEMBER_ID | COUNT_TRANSACTIONS_IN_QUEUE | COUNT_TRANSACTIONS_CHECKED | COUNT_CONFLICTS_DETECTED | COUNT_TRANSACTIONS_ROWS_VALIDATING | LAST_CONFLICT_FREE_TRANSACTION | COUNT_TRANSACTIONS_REMOTE_IN_APPLIER_QUEUE | COUNT_TRANSACTIONS_REMOTE_APPLIED | COUNT_TRANSACTIONS_LOCAL_PROPOSED | COUNT_TRANSACTIONS_LOCAL_ROLLBACK |
+--------------------------------------+-----------------------------+----------------------------+--------------------------+------------------------------------+-----------------------------------------+--------------------------------------------+-----------------------------------+-----------------------------------+-----------------------------------+
| e0dd6e3d-8936-11ea-9176-0242ac150003 | 0 | 167 | 0 | 1 | 8cb61fd9-8931-11ea-ad6f-0242ac110003:43 | 0 | 21 | 146 | 0 |
| e3f0850e-8936-11ea-98ba-0242ac150004 | 0 | 167 | 0 | 1 | 8cb61fd9-8931-11ea-ad6f-0242ac110003:43 | 0 | 151 | 17 | 0 |
| e4a14f46-8936-11ea-b379-0242ac150005 | 0 | 167 | 0 | 1 | 8cb61fd9-8931-11ea-ad6f-0242ac110003:43 | 0 | 166 | 4 | 0 |
+--------------------------------------+-----------------------------+----------------------------+--------------------------+------------------------------------+-----------------------------------------+--------------------------------------------+-----------------------------------+-----------------------------------+-----------------------------------+
三、MGR_ProxySQL
了解了MGR的集群后,还需要在该集群上进行代理的搭建,以便于读写及宕机等情况的调度,完成高可用。常用的解决方案有:ProxySQL和MySQL Router。现简单介绍下ProxySQL+MGR:
即:ProxySQL作为数据库集群的代理,Client通过连接ProxySQL访问数据库,ProxySQL则按照配置的规则,将请求分发到不同的MySQL实例,而ProxySQL后端的MySQL实例,为原生的MGR集群。ProxySQL可查阅:
效果为:
以上是关于MySQL手记20 -- MySQL Group Replication(MGR组复制)的主要内容,如果未能解决你的问题,请参考以下文章