Skip to content

Quick Start: MySQL Replication

Deploy a three-node master/slave replication setup from a single command. Assumes you have already downloaded MySQL 8.4 (see Quick Start: MySQL Single).

  • dbdeployer installed and MySQL 8.4 unpacked in ~/opt/mysql/
  • If you haven’t done this yet, follow step 1 from Quick Start: MySQL Single
Terminal window
dbdeployer deploy replication 8.4.8

Expected output:

Replication directory installed in $HOME/sandboxes/rsandbox_8_4_4
master on port 20192
slave1 on port 20193
slave2 on port 20194

dbdeployer starts one master and two slaves and wires up replication automatically.

Terminal window
~/sandboxes/rsandbox_8_4_4/check_slaves

You should see Seconds_Behind_Master: 0 for each slave, confirming replication is healthy.

Connect to the master:

Terminal window
~/sandboxes/rsandbox_8_4_4/m

Connect to slave 1 or slave 2:

Terminal window
~/sandboxes/rsandbox_8_4_4/s1
~/sandboxes/rsandbox_8_4_4/s2

Try writing on the master and reading on a slave:

-- on master
CREATE DATABASE demo;
USE demo;
CREATE TABLE t (id INT);
INSERT INTO t VALUES (1);
-- on slave (s1 or s2)
USE demo;
SELECT * FROM t;
Terminal window
dbdeployer delete rsandbox_8_4_4