This is the 8th day of my participation in the August More Text Challenge. For details, see:August is more challenging

Message compression

This compression mainly refers to MySQL’s bin-log compression, and the compression algorithm used is LZ4. When network bandwidth is the bottleneck, message compression can provide up to 30-40% throughput improvement at the group communication level, which is particularly important in groups with high network traffic pressure. LZ4 can very well support multi-threaded environment, get higher compression and decompression speed. The following is the compression and decompression of the compression algorithm LZ4:

Compression occurs at the group communication engine level after the data was given to the group communication thread, so it occurs in the context of the mysql user session thread. Transaction-valid network loads can be compressed before being sent to a group and decompressed upon receipt. Compression is conditional and depends on the configured threshold. Compression is enabled by default. In addition, it does not require that all server nodes in the group have compression enabled. Upon receiving a message, the member checks the message envelope to verify that it is compressed, decompresses the transaction if necessary, and passes it to the upper layer.

By default, compression is enabled and the threshold is 1 million bytes (1MB). The compression threshold (in bytes) can be set to be greater than the default value. In this case, only transactions with payloads greater than the threshold are compressed. Here is an example of how to set the compression threshold.

STOP GROUP_REPLICATION;

SET GLOBAL group_replication_compression_threshold= 2097152;

START GROUP_REPLICATION;
Copy the code

This sets the compression threshold to 2MB. If the transaction generates a copy message with a valid content greater than 2MB, such as a binary log transaction entry greater than 2MB, it is compressed. Disable Compression Set the threshold to 0. Note: Modifying this threshold requires restarting group replication.

The message compression flowchart is as follows:

Requirements and restrictions on group replication

Limitations and requirements

    1. All data involved must occur within the tables of the InnoDB storage engine.
    1. All tables must have an explicit primary key definition.
    1. Only IPv4 addresses are supported.
    1. Low latency, high bandwidth networks are required.
    1. Currently, a cluster is limited to a maximum of nine nodes.
    1. Binlog must be enabled.
    1. The binlog format must be ROW format.
    1. Gtid mode must be turned on.
    1. You must use table storage to replicate related information.
  • Transaction write set extraction must be turned on. (This currently conflicts with savePoint, which is why mysqldump cannot back up GR instances)

    1. Log Slave Updates must be enabled.
    1. The checksum of binlog is currently not supported.
    1. Savepoint cannot be used due to interference with the transaction write set.
    1. Currently, the SERIALIZABLE isolation level is not supported.
    1. It is possible to execute DDL in parallel (even conflicting DDLS) on different instances of the same object in the cluster, but it can lead to errors in data consistency and so on. At present, DDL execution of the same object on multiple nodes is not supported.
    1. The current implementation of cascading constraint operations on foreign keys is not fully supported and is not recommended.

Set of copyConfiguration related to

Based on group replication requirements and restrictions, the following Settings configure replication based on MySQL group replication requirements:

server_id = 1

gtid_mode = ON

enforce_gtid_consistency = ON

master_info_repository = TABLE

relay_log_info_repository = TABLE

binlog_checksum = NONE

log_slave_updates = ON

log_bin = binlog

binlog_format = ROW
Copy the code

At this point, the my.cnf file ensures the server configuration and indicates instantiating the replication infrastructure under a given configuration. The following sections configure group replication Settings for the server. The specific parameters are relatively simple and will not be described here. Please refer to the official instructions:

Transaction_write_set_extraction = XXHASH64 loose-group_replication_group_name = "aaaaaaaaA-aaaaa-aaaaa-aaaaa-aaaaaAAA" Loose -group_replication_start_on_boot = off loose-group_replication_local_address ="127.0.0.1:24901" Loose - group_replication_group_seeds = "127.0.0.1:24901127.00 0.1:24902127.00 0.1:24903" loose-group_replication_bootstrap_group = offCopy the code

The specific installation and deployment of group replication are simple and have been explained online and in official instructions. The installation and deployment are not described here.