MySQL 8.0.17 Clone Plugin: How to Create a Slave from Scratch

MySQL 8.0.17 Clone PluginIn this post, we will discuss a new feature – the MySQL 8.0.17 clone plugin. Here I will demonstrate how easy it is to use to create the “classic” replication, building the standby replica from scratch.

The clone plugin permits cloning data locally or from a remote MySQL server instance. The cloned data is a physical snapshot of data stored in InnoDB, and this means, for example, that the data can be used to create a standby replica.

Let’s go to the hands-on and see how it works.

Installation & validation process of the MySQL 8.0.17 clone plugin

Installation is very easy and it works in the same as installing other plugins. Below is the command line to install the clone plugin:

And how to check if the clone plugin is active:

Note that these steps need to be executed on the Donor (aka master) and on the Recipient (aka slave if the clone is being used to create a replica).

After executing the installation, the plugin will be loaded automatically across restarts, so you don’t need to worry about this anymore.

Next, we will create the user with the necessary privilege on the Donor, so we can connect to the instance remotely to clone it.

As a security measure, I recommend replacing the % for the IP/hostname or network mask of the Recipient so the connections will be accepted only by the future replica server.  Now, on the Recipient server, the clone user requires the CLONE_ADMIN privilege for replacing recipient data, blocking DDL during the cloning operation and automatically restarting the server.

Next, with the plugin installed and validated, and users created on both Donor and Recipient servers, let’s proceed to the cloning process.

Cloning process

As mentioned, the cloning process can be executed locally or remotely.  Also, it supports replication, which means that the cloning operation extracts and transfers replication coordinates from the donor and applies them on the recipient. It can be used for GTID or non-GTID replication.

So, to begin the cloning process, first, let’s make sure that there’s a valid donor. This is controlled by clone_valid_donor_list parameter. As it is a dynamic parameter, you can change it while the server is running. Using the show variables command will show if the parameter has a valid donor:

In our case, we need to set it. So let’s change it:

The next step is not mandatory, but using the default log_error_verbosity the error log does not display much information about the cloning progress. So, for this example, I will adjust the verbosity to a higher level (on the Donor and the Recipient):

Now, let’s start the cloning process on the Recipient:

It is possible to observe the cloning progress in the error log of both servers. Below is the output of the Donor:

And the Recipient: