MySQL Study Notes 13 group replication concepts, mysql Study Notes 13 groups
The main content of this article is as follows:
1. Background of group Replication
2. Comparison of several Replication technologies
3. Failure Detection
4. Group members
5. Fault Tolerance
6. Member node status
7. Two group replication Modes
8. Donor nodes
1.
Background of group Replication
The common replication system composed of multiple MySQL services must be maintained and managed. The MySQL group replication technology uses the MySQL group communication protocol to provide the following benefits:
(1) provide automatic coordination between MySQL services in the group.
(2) groups that support a single or multiple Primary systems.
(3) Grouping of a single Primary system supports automated Primary elections.
(4) groups of multiple Primary systems support Automatic Updates received by all Primary systems.
(5) the built-in grouping Service provides data consistency and availability in the group.
Application scenarios of MySQL group replication technology:
(1) elastic replication.
It can dynamically increase or decrease the number of MySQL Service hosts.
(2) highly available parts. As a popular scale-out method, Sharding technology provides a highly available solution for each shard in a MySQL group.
(3) Replace master-slave replication. In a specific scenario, master-slave replication has a single point of pressure. MySQL groups provide better scalability solutions.
(4) Autonomous System. The built-in replication protocol supports automated MySQL grouping.
2.
Comparison of several Replication technologies
The differences between several Replication technologies provided by MySQL are as follows:
(1) asynchronous replication technology.
(2) semi-synchronous replication technology.
(3) group replication technology.
3. Failure Detection
MySQL group replication provides a failure detection mechanism to detect and report which MySQL services are in the unresponsive State. These unresponsive MySQL services are assumed to have crashed. This suspension is only a suspicious situation. Then, if the group agrees that this suspicious situation is true, the Group determines that the MySQL service has actually expired. Finally, other members in the group remove the MySQL service from the group by coordinating the decision. No response indicates that a MySQL service does not receive a response message from another MySQL service within the specified time.
When a MySQL service is excluded from the group, the MySQL service will also detect that all other MySQL services have no response, so the MySQL service will suspect that all other MySQL services have crashed, however, the MySQL service cannot execute any local transaction because it cannot be confirmed.
4.
Group members
MySQL group replication relies on a distributed service called the MySQL group member service, which is provided in the form of a MySQL built-in plug-in. The member service defines which MySQL services are online and are involved in group transactions. The online status list is provided in the form of a view. Each group member can obtain a consistent view.
When a MySQL service is added to a MySQL group or left the group actively or passively, the group service updates this view.
5.
Fault Tolerance
The MySQL Group Member Service uses the PAXOS distributed algorithm to ensure distributed consistency. PAXOS distributed algorithm introduction, please refer to this page: https://baike.baidu.com/item/Paxos%20%E7% AE %97%E6%B3%95
The relationship between the number of MySQL group members and fault tolerance is determined by the following formula:
N = 2 x f + 1
F indicates fault tolerance, and n indicates the number of group members. The fault tolerance here is the maximum number of services that can be faulty without affecting the normal operation of the service.
6.
Member node status
The node status of a member is as follows:
Status |
Synchronization |
Description |
ONLINE |
Yes |
The node is online. All groups are supported. Transactions can be executed at any time. |
RECOVERING |
No |
The node is online. In the recovery status. Receiving data from the donor (donor. |
OFFLINE |
No |
The node is not online. Does not belong to any group. |
ERROR |
No |
Error. Super_read_only is automatically set to ON. You need to manually modify this variable. |
UNREACHABLE |
No |
Inaccessibility status. The node is considered unresponsive or has crashed. |
7.
Two modes of group Replication
MySQL group replication provides two modes:
(1) Single-master mode.
In a group, only one member is in Primary mode, while other members are in Secondary mode. Nodes in Primary mode provide read/write services, while nodes in Secondary mode only provide read-only services.
(2) Multi-master mode.
In a group, multiple members are in Primary mode and the remaining members are in Secondary mode. Nodes in Primary mode provide read/write services, while nodes in Secondary mode only provide read-only services.
Single-master mode and multi-master mode are determined by system variables.
Group_replication_single_primary_mode:
ON: Single-master mode.
OFF: Multi-master mode.
By default, group replication is in single-master mode.
8.
Donor Node
In the MySQL group replication system, a node is required to provide data for other nodes to copy. The Node providing data is called a donor node ). The donor nodes are randomly generated. In a replication system, each node takes turns as the donor node. If the current donor node cannot be connected, use the backup donor node. MySQL tries its best to ensure that the supplied nodes are different each time.