MySQL 8.4 LTS gives you two pieces that, together, take most of the tedium out of building a read replica: the CLONE plugin, which streams a running instance’s InnoDB pages straight into an empty server over the network, and GTID auto-positioning, which lets that new server work out for itself where to resume reading the binary log. No overnight mysqldump, no staging directory for a physical backup, no binlog filename and offset copied by hand and mistyped at 2 a.m. This guide takes two MySQL 8.4 servers — db-a (source, 10.20.0.11) and db-b (replica, 10.20.0.12) — from a standalone install to a verified replication pair, and is explicit about the syntax 8.4 removed rather than merely deprecated, because that is where 8.0-era runbooks now fall over.
What you’ll accomplish
- A source instance with binary logging and
gtid_mode=ON, switched on without a restart if you cannot take one. - Two accounts on the source —
BACKUP_ADMINfor the clone,REPLICATION SLAVEfor the replication channel — and a localCLONE_ADMINaccount on the replica. - A replica whose data directory was filled by one
CLONE INSTANCE FROMstatement, with the donor’sgtid_executedalready inherited. - A running channel configured with
SOURCE_AUTO_POSITION=1, verified throughSHOW REPLICA STATUSand theperformance_schemareplication tables. - A list of the 8.0 statements that now return a syntax error, so your scripts get fixed once instead of failing twice.
Prerequisites
- Two hosts running MySQL 8.4 LTS (8.4.0 or later), same version on both sides. The clone plugin will not copy between different MySQL versions, nor between different operating systems or architectures. Check
SELECT VERSION();on both before you plan anything. - All data in InnoDB. MyISAM and CSV tables are not cloned with their contents — they arrive empty, which is silent data loss if you do not check first.
- Root or equivalent on both hosts, plus the ability to restart
mysqldon the replica. - Free disk on the replica at least as large as the source’s data directory. The clone drops the replica’s existing data before writing, so the copies never coexist, but recovery still wants headroom.
- Network reachability on 3306 from replica to source, and a plan for TLS. If the servers are not on one private network, read cross-region MySQL replication over TLS first — the certificate work there applies to the clone channel as much as the replication channel.
- Honest version note: this all works on MySQL 8.0.17 and later too, but with the old keywords —
CHANGE MASTER TO ... MASTER_AUTO_POSITION=1,START SLAVE. Those spellings were deprecated in 8.0.22/8.0.23 and removed in 8.4, where they now return a plain syntax error. This guide uses 8.4 spelling throughout.
How it works
A remote clone is a two-party operation. The donor is a normal, running MySQL server with the clone plugin loaded; it keeps serving traffic throughout. The recipient connects out to the donor as an ordinary client, drops whatever is in its own data directory, and receives InnoDB pages plus the redo generated during the copy. When the transfer finishes it restarts itself and performs InnoDB recovery, coming up as a consistent point-in-time copy of the donor.
The part that matters for replication is the GTID handoff. The clone carries the donor’s gtid_executed set across and installs it on the recipient as gtid_purged. That single fact makes the next step trivial: the replica already knows, in globally unique transaction identifiers rather than file-and-offset coordinates, exactly which transactions it holds. Set SOURCE_AUTO_POSITION=1 and the replica hands that set to the source during the connection handshake; the source works out which binary log to start reading from. You never touch a coordinate.
Three things the clone does not do, and each one has bitten somebody:
- It does not copy configuration files.
server_id,gtid_modeand everything else inmy.cnfstay whatever the replica’s own file says — which is what stops the replica coming up with a duplicateserver_id. - It does not copy binary logs or relay logs. If the source purges a binlog the replica still needs, auto-positioning fails with a fatal error rather than silently skipping ahead.
- It does copy the
mysqlschema — accounts, grants, everything. After the clone you authenticate against the replica with the donor’s credentials.
MySQL 8.4 also changed replication defaults you no longer need to set by hand. replica_parallel_workers defaults to 4 instead of 0, so multi-threaded apply is on out of the box, and replica_preserve_commit_order defaults to ON, keeping commit order identical to the source’s. binlog_transaction_dependency_tracking now defaults to WRITESET rather than COMMIT_ORDER, giving those workers far more to chew on; the variable is itself deprecated in 8.4, so leave it alone.
Step-by-step
First, confirm the clone plugin is the right tool for your data. It is the default answer for an all-InnoDB pair on matching versions, and the wrong answer in several common situations.
-
Turn on binary logging and GTIDs on the source. Binary logging is on by default in 8.4; GTIDs are not. Add this to
/etc/mysql/mysql.conf.d/mysqld.cnf(Debian, Ubuntu) or/etc/my.cnf(RHEL family) ondb-a:[mysqld] server_id = 1 log_bin = /var/lib/mysql/binlog gtid_mode = ON enforce_gtid_consistency = ON binlog_expire_logs_seconds = 1209600Restart, then confirm:
sudo systemctl restart mysql mysql -e "SELECT @@server_id, @@gtid_mode, @@enforce_gtid_consistency, @@log_bin;"Expected:
1,ON,ON,1. Note the retention value — fourteen days. Set it too short and a long clone plus a slow first sync will outrun the logs the replica needs. -
Or switch GTIDs on without a restart. If
db-ais in production, MySQL supports an online transition. Run the steps in order and do not skip the check.SET @@GLOBAL.enforce_gtid_consistency = WARN; SET @@GLOBAL.enforce_gtid_consistency = ON; SET @@GLOBAL.gtid_mode = OFF_PERMISSIVE; SET @@GLOBAL.gtid_mode = ON_PERMISSIVE; SHOW STATUS LIKE 'Ongoing_anonymous_transaction_count';Expected:
Ongoing_anonymous_transaction_countreaches0. Only then:SET @@GLOBAL.gtid_mode = ON;Expected:
Query OK. LeaveWARNrunning a while first and watch the error log — it names any statement your application uses that GTID mode will not tolerate (CREATE TABLE ... SELECT, mixing transactional and non-transactional tables in one transaction). Write the settings intomy.cnfafterwards, or the next restart undoes it. -
Create the two accounts on the source. They do different jobs. The clone account needs
BACKUP_ADMIN; the replication account needsREPLICATION SLAVE— a privilege name that was not renamed in 8.4, which surprises people who expected the terminology change to be total.CREATE USER 'clone_src'@'10.20.0.%' IDENTIFIED BY 'CHANGE_ME_CLONE'; GRANT BACKUP_ADMIN ON *.* TO 'clone_src'@'10.20.0.%'; CREATE USER 'repl'@'10.20.0.%' IDENTIFIED BY 'CHANGE_ME_REPL' REQUIRE SSL; GRANT REPLICATION SLAVE ON *.* TO 'repl'@'10.20.0.%';Verify:
SHOW GRANTS FOR 'clone_src'@'10.20.0.%'; SHOW GRANTS FOR 'repl'@'10.20.0.%';Expected:
GRANT BACKUP_ADMIN ON *.*for the first,GRANT REPLICATION SLAVE ON *.*for the second. Both getcaching_sha2_password, becausemysql_native_passwordis no longer enabled at startup in 8.4. Keep it that way and use TLS. -
Install the clone plugin on both servers. It ships with MySQL but is not loaded by default. Run this on
db-aand again ondb-b:INSTALL PLUGIN clone SONAME 'mysql_clone.so'; SELECT PLUGIN_NAME, PLUGIN_STATUS FROM information_schema.PLUGINS WHERE PLUGIN_NAME = 'clone';Expected: one row,
clone/ACTIVE. The registration lives in themysqlschema, so it survives restarts; to pin it in configuration instead, addplugin-load-add=mysql_clone.sotomy.cnf. -
Prepare the replica’s configuration.
db-bneeds a distinctserver_idand its own GTID settings, and should come up quiet rather than connecting to anything.[mysqld] server_id = 2 log_bin = /var/lib/mysql/binlog relay_log = /var/lib/mysql/relay-bin gtid_mode = ON enforce_gtid_consistency = ON skip_replica_start = ON read_only = ON super_read_only = ONsudo systemctl restart mysql mysql -e "SELECT @@server_id, @@super_read_only, @@replica_parallel_workers;"Expected:
2,1,4. That4is the 8.4 default forreplica_parallel_workers; on 8.0 the same query returns0. -
Authorise the donor on the replica. The recipient will only clone from a host you have explicitly listed, and the local account running the statement needs
CLONE_ADMIN. Setting the donor list is a global variable change, so grantSYSTEM_VARIABLES_ADMINtoo — forgetting that is the most common stumble here.CREATE USER 'clone_admin'@'localhost' IDENTIFIED BY 'CHANGE_ME_ADMIN'; GRANT CLONE_ADMIN, SYSTEM_VARIABLES_ADMIN ON *.* TO 'clone_admin'@'localhost';Then, connected as that account:
SET GLOBAL clone_valid_donor_list = '10.20.0.11:3306'; SELECT @@GLOBAL.clone_valid_donor_list;Expected:
10.20.0.11:3306echoed back. The port is not optional, and the value is a comma-separated list rather than a pattern — wildcards are rejected. -
Run the clone. One statement on
db-b, asclone_admin.CLONE INSTANCE FROM 'clone_src'@'10.20.0.11':3306 IDENTIFIED BY 'CHANGE_ME_CLONE' REQUIRE SSL;Expected:
Query OK, 0 rows affectedafter a long pause — orERROR 2013 (HY000): Lost connection to MySQL server during query, equally normal, because the recipient restarts itself at the end and takes your session with it. Watch progress from a second session:SELECT STAGE, STATE, END_TIME FROM performance_schema.clone_progress;Expected: rows walking through
DROP DATA,FILE COPY,PAGE COPY,REDO COPY,FILE SYNC,RESTART,RECOVERY, each moving toCompleted.FILE COPYis where the time goes. -
Confirm the restart and the inherited GTID set. Reconnect once
mysqldis back, using the donor’s credentials — the account table came across with everything else.SELECT STATE, ERROR_NO, BINLOG_FILE, BINLOG_POSITION FROM performance_schema.clone_status\G SELECT @@GLOBAL.gtid_purged\GExpected:
STATE: Completed,ERROR_NO: 0, and agtid_purgedlike3e11fa47-71ca-11e1-9e33-c80aa9429562:1-58291— the donor’s UUID and executed range. An emptygtid_purgedmeans the source had GTIDs off when you cloned; go back to step 1. -
Point the replica at the source. This is the statement whose 8.0 spelling no longer parses.
CHANGE REPLICATION SOURCE TO SOURCE_HOST = '10.20.0.11', SOURCE_PORT = 3306, SOURCE_USER = 'repl', SOURCE_PASSWORD = 'CHANGE_ME_REPL', SOURCE_SSL = 1, SOURCE_AUTO_POSITION = 1;Expected:
Query OK, 0 rows affectedplus warnings about storing the password in the replication metadata. That is why some teams pass credentials at start time withSTART REPLICA USER = ... PASSWORD = ...instead; neither approach is secret-safe on its own. -
Start replication and look at it immediately.
START REPLICA; SHOW REPLICA STATUS\GExpected, in the fields that matter:
Replica_IO_Running: Yes,Replica_SQL_Running: Yes,Auto_Position: 1,Last_IO_ErrorandLast_SQL_Errorempty, andSeconds_Behind_Sourcecounting down to0.Retrieved_Gtid_Setgoes non-empty within seconds of any write on the source.
Validate it works
Check the connection and the applier separately — SHOW REPLICA STATUS collapses two different failure modes into one screen.
SELECT SERVICE_STATE, LAST_ERROR_MESSAGE
FROM performance_schema.replication_connection_status\G
SELECT WORKER_ID, SERVICE_STATE, LAST_ERROR_MESSAGE
FROM performance_schema.replication_applier_status_by_worker;
Expected: SERVICE_STATE: ON with an empty error from the first, and four rows from the second, all ON — one per default parallel worker. Fewer than four means replica_parallel_workers was overridden somewhere.
Now prove data actually moves. On db-a:
CREATE DATABASE IF NOT EXISTS repl_check;
CREATE TABLE repl_check.beat (id INT PRIMARY KEY, seen TIMESTAMP);
INSERT INTO repl_check.beat VALUES (1, NOW());
SELECT @@GLOBAL.gtid_executed\G
On db-b, substituting the set you just read from the source for <source set>:
SELECT * FROM repl_check.beat;
SELECT GTID_SUBTRACT('<source set>', @@GLOBAL.gtid_executed) AS missing\G
Expected: the row appears, and missing is an empty string — the replica has executed every transaction the source has. A non-empty missing that shrinks on re-run is lag; one that does not shrink is a stall.
Finally, confirm the replica cannot be written to by accident:
mysql -e "SELECT @@read_only, @@super_read_only;"
Expected: 1 and 1. Without super_read_only, any account holding CONNECTION_ADMIN can still write and break the GTID chain.
Troubleshooting
ERROR 1064onSTART SLAVE,SHOW SLAVE STATUSorCHANGE MASTER TO. Not deprecated — gone. SubstituteSTART REPLICA,SHOW REPLICA STATUSandCHANGE REPLICATION SOURCE TO. The other removals that catch scripts:SHOW MASTER STATUSis nowSHOW BINARY LOG STATUS,SHOW SLAVE HOSTSisSHOW REPLICAS,RESET SLAVEisRESET REPLICA, andRESET MASTERisRESET BINARY LOGS AND GTIDS. Grep your runbooks forMASTER_andSLAVEin one pass.- The clone fails with a donor error naming
BACKUP_ADMIN. The recipient wraps the donor’s error, so the message describes a privilege on a server you are not connected to. CheckSHOW GRANTS FOR 'clone_src'@'10.20.0.%';ondb-a. A near-identical failure happens when the host pattern does not match the replica’s source address. - The clone is rejected before it starts, naming
clone_valid_donor_list. Either the variable is empty, or you set it without the port, or you set it per session. It is global only. Re-runSET GLOBAL clone_valid_donor_list = 'host:port';as an account withSYSTEM_VARIABLES_ADMIN. - The recipient never comes back, with
Restart server failed (mysqld is not managed by supervisor process). The clone finished but the auto-restart could not fire, becausemysqldwas started by hand rather than under systemd ormysqld_safe. Nothing is lost:sudo systemctl start mysql, let recovery finish, then checkperformance_schema.clone_statusforCompleted. Replica_IO_Running: Connectingwith an authentication error mentioningcaching_sha2_password. In 8.4mysql_native_passwordis off at startup, soreplusescaching_sha2_password, which will not send credentials over a plaintext channel unless it can fetch the source’s public key. KeepSOURCE_SSL = 1— the right answer — or, on a trusted private link, addGET_SOURCE_PUBLIC_KEY = 1to theCHANGE REPLICATION SOURCE TOstatement.Got fatal error 1236saying the source purged binary logs containing GTIDs the replica requires. The gap between the cloned snapshot and the oldest surviving binary log is real and no restart will bridge it. This is whatbinlog_expire_logs_secondswas for in step 1: raise retention on the source, then clone again.
When this is the wrong approach
The clone plugin only understands InnoDB. If the schema still carries MyISAM or CSV tables, those arrive empty and replication then happily applies changes to rows that were never seeded. Convert them first with ALTER TABLE ... ENGINE=InnoDB, or seed with mysqldump and accept the slower restore.
It also will not cross a version or a platform boundary. Moving from 8.0 to 8.4, from x86 to ARM, or from RHEL to Ubuntu means a logical dump. The same goes for MariaDB in either direction: there is no clone plugin there, and its GTID implementation is a different design with different syntax.
On managed platforms — RDS, Aurora, Cloud SQL — you do not get CLONE_ADMIN and you do not need it: use the provider’s read-replica feature, which does the equivalent work underneath. Shared hosting is its own category; see adding a MySQL read replica to a cPanel account for what is possible when the control panel owns the configuration.
Finally, remember what a replica is not. It follows the source, including the DROP TABLE somebody ran at 4 p.m. It protects you from a dead server, not from a bad statement, so it belongs alongside real backups rather than in place of them.
Keep the MySQL 8.4 clone plugin documentation and the replication with GTIDs chapter open while you work.
If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.