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).
Prerequisites
Section titled “Prerequisites”- 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
1. Deploy replication
Section titled “1. Deploy replication”dbdeployer deploy replication 8.4.8Expected output:
Replication directory installed in $HOME/sandboxes/rsandbox_8_4_4master on port 20192slave1 on port 20193slave2 on port 20194dbdeployer starts one master and two slaves and wires up replication automatically.
2. Check replication status
Section titled “2. Check replication status”~/sandboxes/rsandbox_8_4_4/check_slavesYou should see Seconds_Behind_Master: 0 for each slave, confirming replication is healthy.
3. Connect to master and slaves
Section titled “3. Connect to master and slaves”Connect to the master:
~/sandboxes/rsandbox_8_4_4/mConnect to slave 1 or slave 2:
~/sandboxes/rsandbox_8_4_4/s1~/sandboxes/rsandbox_8_4_4/s2Try writing on the master and reading on a slave:
-- on masterCREATE DATABASE demo;USE demo;CREATE TABLE t (id INT);INSERT INTO t VALUES (1);
-- on slave (s1 or s2)USE demo;SELECT * FROM t;4. Clean up
Section titled “4. Clean up”dbdeployer delete rsandbox_8_4_4What’s next?
Section titled “What’s next?”- Replication topologies — fan-in, all-masters, semi-sync
- Group Replication — single-primary and multi-primary
- Quick Start: ProxySQL Integration