From 71396f37c7a8206343cac25fef7a1b3b4a276346 Mon Sep 17 00:00:00 2001 From: Simon Cornet Date: Mon, 19 Jan 2026 15:02:15 +0100 Subject: [PATCH] feat: mysql replica documentation improvement --- docs/linux/mysql-replication.md | 94 +++++++++++++++++++++++++-------- 1 file changed, 73 insertions(+), 21 deletions(-) diff --git a/docs/linux/mysql-replication.md b/docs/linux/mysql-replication.md index daf4fc7..119e9d9 100644 --- a/docs/linux/mysql-replication.md +++ b/docs/linux/mysql-replication.md @@ -14,12 +14,22 @@ MariaDB: ```shell [mysqld] + +# server identification server-id = 1 + +# network +bind-address = 0.0.0.0 + +# gtid configuration +gtid_strict_mode = 1 + +# binary logging log-bin = /var/log/mysql/mysql-bin.log binlog-format = ROW binlog-do-db = databeast -bind-address = 0.0.0.0 -gtid_strict_mode = 1 + +# replication configuration log_slave_updates = 1 ``` @@ -27,13 +37,24 @@ MySQL: ```shell [mysqld] + +# server identification server-id = 1 -log_bin = /var/lib/mysql/mysql-bin.log -binlog_format = ROW -binlog-expire-logs-seconds = 172800 -max_binlog_size = 100M + +# network +bind-address = 0.0.0.0 + +# gtid configuration gtid_mode = ON enforce_gtid_consistency = ON + +# binary logging +log_bin = /var/lib/mysql/mysql-bin.log +binlog_format = ROW +max_binlog_size = 100M +binlog-expire-logs-seconds = 172800 + +# replication configuration log_slave_updates = 1 ``` @@ -58,13 +79,13 @@ FLUSH PRIVILEGES; MariaDB: ```shell -mariadb-dump -u root -psupersecuresource --single-transaction --gtid --master-data=1 --databases databeast > /tmp/databeast.sql +mariadb-dump -u root -psupersecuresource --single-transaction --gtid --databases databeast > /tmp/databeast.sql ``` MySQL: ```shell -mysqldump -u root -psupersecuresource --single-transaction --set-gtid-purged=ON --source-data=1 --databases databeast > /tmp/databeast.sql +mysqldump -u root -psupersecuresource --single-transaction --set-gtid-purged=ON --source-data=2 --databases databeast > /tmp/databeast.sql ``` ## Configure replicate @@ -79,33 +100,64 @@ MariaDB: ```shell [mysqld] + +# server identification server-id = 2 -read-only = 1 -relay-log = /var/log/mysql/mysql-relay-bin + +# network +bind-address = 0.0.0.0 + +# gtid configuration +gtid_strict_mode = 1 + +# binary logging log-bin = /var/log/mysql/mysql-bin.log binlog-format = ROW -bind-address = 0.0.0.0 -gtid_strict_mode = 1 + +# replication configuration log_slave_updates = 1 +relay-log = /var/log/mysql/mysql-relay-bin + +# parallel replication +slave_parallel_mode = optimistic +slave_parallel_threads = 2 + +# read-only replica +read-only = 1 ``` MySQL: ```shell [mysqld] + +# server identification server-id = 2 -relay_log = /var/lib/mysql/mysql-relay-bin -read_only = 1 -replicate-do-db = databeast -log_bin = /var/lib/mysql/mysql-bin.log -binlog_format = ROW -binlog-expire-logs-seconds = 172800 -max_binlog_size = 100M + +# network +bind-address = 0.0.0.0 + +# gtid configuration gtid_mode = ON enforce_gtid_consistency = ON + +# binary logging +log_bin = /var/lib/mysql/mysql-bin.log +binlog_format = ROW +max_binlog_size = 100M +binlog-expire-logs-seconds = 172800 + +# replication configuration log_slave_updates = 1 -slave_parallel_type = 'LOGICAL_CLOCK' +relay_log = /var/lib/mysql/mysql-relay-bin +replicate-do-db = databeast + +# parallel replication +slave_parallel_type = LOGICAL_CLOCK slave_parallel_workers = 2 + +# read-only replica +read_only = 1 ``` Restart mariadb: `systemctl restart mariadb` @@ -187,7 +239,7 @@ mysql -u root -p ``` ```shell -SHOW REPLICA STATUS\G +SHOW SLAVE STATUS\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: source.example.com