MySQL Clone Plugin in Group Replication and fine-tuning clone plugin

Mydbops
Sep 28, 2023
12
Mins to Read
All

MySQL, one of the most widely used relational database management systems, offers an array of features to simplify database management and replication. Among these features, the MySQL Clone Plugin stands out as a powerful tool within the context of Group Replication. The MySQL Clone Plugin is a remarkable addition to MySQL's toolkit, introduced in MySQL 8.0.17 and later versions. It addresses a common challenge in database management: the efficient and rapid cloning of database instances.

In this blog, we'll delve deeper into the Clone Plugin's setup, configuration, and advanced features. By the end, you'll have a comprehensive understanding of how to harness the full potential of the MySQL Clone Plugin within Group Replication to optimize your database management and replication processes.

MySQL Clone Plugin

Prior to MySQL 8.0.17, we had two primary choices for performing backups: utilizing Xtrabackup or opting for logical backup methods such as mysqldump or mydumper. With Xtrabackup, after the backup completion, the subsequent steps involve preparing the backup, bringing up the server, and subsequently configuring the group replication manually. On the other hand, opting for a logical backup entails a lengthier restoration process, largely influenced by the size of the data being restored.

The MySQL Clone Plugin changes this landscape by enabling the effortless duplication of a physical database snapshot across local and remote servers. When integrated into a Group Replication setup, it can seamlessly incorporate a new node into the replication group with minimal manual intervention. This automation significantly streamlines the synchronization of data, reducing the complexity of database replication.

Preliminary Evaluations

Before diving into the MySQL Clone Plugin's functionality within Group Replication, several prerequisites must be met to ensure a smooth cloning process. These include:

  • Group Replication Setup: At least one primary node within your Group Replication setup.
  • Clone Plugin: Ensure the MySQL Clone Plugin is installed and available.
  • Port Connectivity: Verify that the necessary ports are open and accessible.
  • Same Server Versions: Ensure that both the donor and recipient nodes are running the same MySQL server version.
  • Corresponding Configuration Files: Make sure that the MySQL configuration file (my.cnf) is appropriately configured on both donor and recipient nodes.

Donor Node

In the group replication setup, the donor node assumes the role of the primary server, serving as the source of data for replication to other nodes.

 
mysql> select MEMBER_HOST,MEMBER_STATE,MEMBER_ROLE from performance_schema.replication_group_members;
+--------------+--------------+-------------+
| MEMBER_HOST  | MEMBER_STATE | MEMBER_ROLE |
+--------------+--------------+-------------+
| Node1        |      ONLINE |   PRIMARY   |
+--------------+--------------+-------------+
2 rows in set (0.00 sec)
	

To facilitate data cloning from the donor server to the recipient node, it is essential to create a dedicated donor user on the donor server. This donor user will be utilized specifically for the purpose of cloning data and ensuring a secure and efficient replication process.

 
mysql> CREATE USER 'donor_clone_user'@'%' IDENTIFIED BY '';
Query OK, 0 rows affected (0.01 sec)


mysql> GRANT BACKUP_ADMIN on *.* to 'donor_clone_user'@'%';
Query OK, 0 rows affected (0.01 sec)


mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
	

Recipient node

The recipient node operates independently and is not integrated into the group replication setup. It remains separate from the replication group and functions as a standalone node without participating in the group replication process.

 
mysql> select MEMBER_HOST,MEMBER_STATE,MEMBER_ROLE from performance_schema.replication_group_members;
+--------------+--------------+-------------+
| MEMBER_HOST  | MEMBER_STATE | MEMBER_ROLE  |
+--------------+--------------+-------------+
| Node2        | OFFLINE      |              |
+--------------+--------------+-------------+
1 row in set (0.00 sec)
	

In order to facilitate data cloning from the donor node, it is necessary to create a recipient user on the recipient node. This dedicated recipient user will be utilized to securely receive and replicate data from the donor node, ensuring a smooth and efficient cloning process. We must ensure the entry of a valid donor node, along with its respective port, in the clone_valid_donor_list.

 
mysql> CREATE USER 'recipient_clone_user'@'%' IDENTIFIED BY '';
Query OK, 0 rows affected (0.01 sec)


mysql> GRANT CLONE_ADMIN on *.* to 'recipient_clone_user'@'%';
Query OK, 0 rows affected (0.01 sec)


mysql> SET GLOBAL clone_valid_donor_list = 'Node1:3306';
Query OK, 0 rows affected (0.00 sec)
	

Configuration File

Prior to initiating the cloning process, it is essential to ensure that all the necessary configurations are appropriately added to my.cnf file, which serves as the default MySQL configuration file. Verifying these settings beforehand will ensure a smooth and successful cloning process, enabling seamless data replication between the donor and recipient nodes.

 
group_replication_transaction_size_limit = x
group_replication_member_expel_timeout=x
group_replication_autorejoin_tries=x
binlog_transaction_dependency_tracking = WRITESET
group_replication_group_name='xxxxxxxxxxx'
group_replication_group_seeds='node1:33061,node2:33061'
group_replication_ip_allowlist='xxxxxxx,xxxxxxx'
group_replication_ip_whitelist='xxxxxxx,xxxxxxx'
	

Initiating Cloning

With all prerequisites and configurations in place, you can initiate the cloning process using the CLONE INSTANCE command. This command clones data from the donor node to the recipient node, setting the stage for data synchronization.

 
mysql> CLONE INSTANCE FROM 'donor_clone_user'@'Node1':3306 IDENTIFIED BY '';
Query OK, 0 rows affected (44.77 sec)
	

Upon completing the cloning process, MySQL will automatically restart, incorporating the preset configurations from the my.cnf file. Group replication will then be initiated, and the cloned node will seamlessly join the replication group, ensuring data synchronization and maintaining a consistent replication environment.

 
mysql> select MEMBER_HOST,MEMBER_STATE,MEMBER_ROLE from performance_schema.replication_group_members;
+--------------+--------------+-------------+
| MEMBER_HOST  | MEMBER_STATE | MEMBER_ROLE |
+--------------+--------------+-------------+
| Node2        |      ONLINE |   SECONDARY |
| Node1        |      ONLINE |   PRIMARY   |
+--------------+--------------+-------------+
2 rows in set (0.00 sec)
	

Fine-Tuning the Cloning Process

MySQL Clone Plugin
Fine-Tuning the Cloning Process

To streamline the cloning process and effectively manage resources, it's essential to enable clone_autotune_concurrency. This feature automatically adjusts cloning concurrency based on resource availability and workload, ensuring efficient resource utilization.

However, in situations where specific resources become saturated, temporarily disabling clone_autotune_concurrency may be necessary. Disabling this feature allows for manual tuning of relevant variables, optimizing performance and resource allocation during cloning.

Please note that the mentioned variables exclusively apply to the recipient server.

System Resource

Variable

Purpose

CPU

clone_max_concurrency

This variable allows you to specify the maximum number of concurrent cloning operations that can be performed. By increasing the value of this variable, you can parallelize the cloning process and improve performance.

IO

clone_max_data_bandwidth

This variable controls the maximum amount of data that can be transferred per second during the cloning process. By increasing this value, you can allocate more bandwidth for data transfer, resulting in a faster cloning process.

Network 

clone_max_network_bandwidth

Similar to clone_max_data_bandwidth, this variable limits the maximum network bandwidth used during the cloning process. Increasing this value can help improve cloning performance by allowing more network resources to be utilized.

clone_enable_compression

Enabling this variable enables compression for the distributed recovery process, reducing the amount of data that needs to be transferred over the network. This can significantly speed up the cloning process, especially when dealing with large datasets.

In conclusion, the introduction of the MySQL Clone Plugin in Group Replication simplifies and accelerates the cloning process significantly. By automating server preparation and startup, it streamlines the otherwise complex task of configuring group replication.

Moreover, the flexibility to fine-tune the process according to server resources ensures faster data rebuilds, making database management more efficient and responsive to evolving needs. Embracing the Clone Plugin empowers administrators to optimize their replication strategies, leading to enhanced performance and data synchronization in MySQL Group Replication environments.

Optimize your MySQL Group Replication setup with Mydbops' InnoDB Cluster Consulting Services. Our experts can help you streamline your database management and improve performance. Contact us today to discuss your specific needs.

{{cta}}

No items found.

About the Author

Mydbops

Subscribe Now!

Subscribe here to get exclusive updates on upcoming webinars, meetups, and to receive instant updates on new database technologies.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.