Master MySQL Clone Plugin: Installation, Usage, and Optimization
This guide explains MySQL 8.0.17's Clone Plugin—how to install it, perform local and remote clones, monitor progress via performance_schema, build replicas from cloned data, understand its internal stages, configure parameters, and compare it with XtraBackup.
Overview
The Clone Plugin, introduced in MySQL 8.0.17, enables a built‑in, single‑command method to clone a MySQL instance for adding nodes to Group Replication or ordinary master‑slave topologies.
Installation
Two installation methods are supported:
Add plugin-load-add=mysql_clone.so to the [mysqld] section of my.cnf and restart the server.
Load the plugin at runtime: INSTALL PLUGIN clone SONAME 'mysql_clone.so'; Verify with SHOW PLUGINS;; the plugin should appear with ACTIVE status.
Local Clone
Clones data from the current instance to a directory on the same host.
Create a clone user with the required privilege:
CREATE USER 'clone_user'@'%' IDENTIFIED BY 'clone_pass';
GRANT BACKUP_ADMIN ON *.* TO 'clone_user'@'%';Prepare an empty, writable directory (absolute path). Example:
mkdir -p /data/backup
chown -R mysql.mysql /data/backupExecute the clone command: CLONE LOCAL DATA DIRECTORY='/data/backup/3307'; Start a new instance that points to the cloned directory:
mysqld --no-defaults --datadir=/data/backup/3307 --user=mysql --port=3307 &Directory requirements: absolute path, must exist, writable by MySQL, and the final sub‑directory (e.g., 3307) must not already exist.
Remote Clone
Clones data from a donor instance to a recipient over the network.
On the donor, create a clone user and load the plugin:
CREATE USER 'donor_user'@'%' IDENTIFIED BY 'donor_pass';
GRANT BACKUP_ADMIN ON *.* TO 'donor_user'@'%';
INSTALL PLUGIN clone SONAME 'mysql_clone.so';On the recipient, create a clone user with CLONE_ADMIN (includes BACKUP_ADMIN and SHUTDOWN) and load the plugin:
CREATE USER 'recipient_user'@'%' IDENTIFIED BY 'recipient_pass';
GRANT CLONE_ADMIN ON *.* TO 'recipient_user'@'%';
INSTALL PLUGIN clone SONAME 'mysql_clone.so';Set the donor whitelist on the recipient (requires SYSTEM_VARIABLES_ADMIN):
SET GLOBAL clone_valid_donor_list='192.168.244.10:3306';Run the remote clone command:
CLONE INSTANCE FROM 'donor_user'@'192.168.244.10':3306 IDENTIFIED BY 'donor_pass' [DATA DIRECTORY='clone_dir'];The remote clone performs the following steps on both donor and recipient:
Acquire a backup lock (DDL is blocked unless clone_block_ddl is OFF).
Drop user tablespaces (system files are renamed with a .#clone suffix).
Copy data files from the donor.
Restart the recipient, replacing original system files with the .#clone versions.
Monitoring Clone Progress
Two performance_schema tables provide insight:
clone_status – a single‑row table showing overall state, timestamps, source/destination, error codes, and GTID/binlog positions.
clone_progress – one row per stage (DROP DATA, FILE COPY, PAGE COPY, REDO COPY, FILE SYNC, RESTART, RECOVERY) with columns such as STAGE, STATE, BEGIN_TIME, END_TIME, THREADS, ESTIMATE, DATA, NETWORK, DATA_SPEED, NETWORK_SPEED.
Building a Replica from Cloned Data
Two replication setups are covered:
GTID‑based replication – enable automatic positioning:
CHANGE MASTER TO MASTER_HOST='master_host', MASTER_PORT=3306, MASTER_AUTO_POSITION=1;
START SLAVE;Position‑based replication – retrieve BINLOG_FILE and BINLOG_POSITION from clone_status and use them:
CHANGE MASTER TO MASTER_HOST='master_host', MASTER_PORT=3306,
MASTER_LOG_FILE='mysql-bin.000004', MASTER_LOG_POS=139952824;
START SLAVE;When using the Clone Plugin, GTID variables ( GTID_PURGED, GTID_EXECUTED) are already correct, so no manual SET GLOBAL GTID_PURGED is required.
Implementation Details
The clone operation consists of five internal phases:
INIT – create a clone object.
FILE COPY – copy InnoDB data files while recording the start LSN and enabling page tracking.
PAGE COPY – copy only the pages that changed after the start LSN, sorted to reduce random I/O; redo archiving is started.
REDO COPY – copy redo logs generated between the start and end LSNs.
DONE – call snapshot_end() to destroy the clone object.
Requirements and Limitations
DDL is blocked on the donor during cloning (except MySQL 8.0.27+ where donor DDL no longer blocks).
Configuration parameters, binary logs, and non‑InnoDB tables are not copied.
Only InnoDB table data is cloned; other storage engines copy only the schema.
Donor and recipient must run the same MySQL version, OS, architecture, character set, and innodb_page_size.
Recipient needs sufficient disk space and must be managed by mysqld_safe or systemd for automatic restart.
Only one clone operation can run on a given instance at a time.
Donor port must be a classic MySQL port (X Protocol ports are not supported).
Clone Plugin vs. Percona XtraBackup
Both perform FILE COPY and REDO COPY; Clone adds a PAGE COPY stage, resulting in faster recovery.
XtraBackup lacks redo archiving, risking loss of redo logs generated during copy.
When using GTID, Clone does not require a manual SET GLOBAL GTID_PURGED step.
Configuration Parameters
clone_autotune_concurrency – ON/OFF automatic thread‑count tuning (default ON; max threads controlled by clone_max_concurrency).
clone_block_ddl – whether to acquire a backup lock on the donor (blocks DDL, default OFF, introduced in 8.0.27).
clone_delay_after_data_drop – wait time after dropping user tablespaces before copying data (default 0 s, introduced in 8.0.29).
clone_buffer_size – size of the local clone buffer (default 4 MiB).
clone_ddl_timeout – max wait time for a backup lock before the clone aborts (default 300 s).
clone_donor_timeout_after_network_failure – wait time after a network error before aborting (default 5 min, configurable from 8.0.24).
clone_enable_compression – enable compression for remote data transfer (default OFF).
clone_max_data_bandwidth – max data copy rate in MiB/s (0 = unlimited).
clone_max_network_bandwidth – max network transfer rate in MiB/s (0 = unlimited).
clone_valid_donor_list – comma‑separated whitelist of donor hosts.
clone_ssl_ca / clone_ssl_cert / clone_ssl_key – SSL configuration for secure remote cloning.
References
InnoDB: Clone local replica – https://dev.mysql.com/worklog/task/?id=9209
InnoDB: Clone remote replica – https://dev.mysql.com/worklog/task/?id=9210
InnoDB: Clone replication coordinates – https://dev.mysql.com/worklog/task/?id=9211
InnoDB: Clone remote provisioning – https://dev.mysql.com/worklog/task/?id=11636
MySQL/InnoDB data clone plugin analysis (Chinese) – https://zhuanlan.zhihu.com/p/79328512
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
dbaplus Community
Enterprise-level professional community for Database, BigData, and AIOps. Daily original articles, weekly online tech talks, monthly offline salons, and quarterly XCOPS&DAMS conferences—delivered by industry experts.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
