WIUNIX ACADEMY
Install MariaDB primary-replica replication with GTID and TLS
Build a fresh primary and read-only replica, seed a consistent InnoDB dataset, secure the channel with verified TLS and prove that new transactions arrive.
Make this guide yoursYOUR SYSTEM. YOUR STEPS.
Where are you working?
Choose your OS and version. The prerequisites, commands and troubleshooting follow your environment.
USE YOUR OWN VALUES
Configure this tutorial
Set the example values for your environment; related explanations and copy panels update together. Never enter passwords, private keys or tokens. Values stay in this tab and are not sent to the server or share links. Check actual DNS, certificates and network policy before running commands.
Different IP addresses, domains or ports? Open the settings below, change the values and select “Apply to tutorial”, then copy the updated commands.
Set values for my environment3 editable values
THE OUTCOME
What will you have at the end?
A dedicated fresh primary and read-only replica with a consistent seed, verified TLS and demonstrated post-seed transaction delivery.
Supported operating systems and versions
Thirteen environment paths reviewed against official documentation on 2026-11-05; no fresh full distro installation matrix. Historical evidence concerns two extracted MariaDB 10.11.14 instances in an isolated network namespace on Ubuntu 24.04.4 only. It does not test host installation, systemd, firewall, private DNS or organizational PKI. Use identical distro packages on both disposable VMs; Arch and Manjaro branches can differ. Illustrative teaching photographs.
Before you begin
- Two fresh systemd hosts on the same reviewed OS and MariaDB package version; sudo/SSH, private addresses, synchronized clocks, minimum 2GB RAM each and capacity for database/logs/backups.
- Existing default-deny private firewall/ACL, verified SSH host keys and internal DNS for db-primary.example.internal. No public3306 access.
- Existing trusted PKI: primary serverAuth certificate with matching DNS SAN/key and CA chain; public CA chain on replica. Secret manager and protected terminal. No application writer until verification.
One writer, one asynchronous copy
Build a dedicated two-node lab: primary 10.20.0.10 (server_id 101), replica 10.20.0.11 (102), domain 0 on both, TCP 3306 only on the private network. Only the primary accepts application writes. The replica receives binary logs over verified TLS and applies them independently. A commit can be acknowledged before it reaches the replica; this is neither synchronous HA nor a backup. Accidental deletes also replicate.
Agree the boundary before installation
Use two fresh disposable VMs on the SAME selected OS release and identical MariaDB package versions. No existing MySQL/MariaDB installation, user database, replication channel or application writer may be present. This guide seeds only academy_lab on dedicated instances; it does not migrate production data or copy users/system schemas. Stop on retained state; do not delete it to pass a guard.
LET’S BUILD
Inspect both fresh hosts
On both hosts, as your existing sudo administrator. The guard aborts on an installed server or retained data/configuration. Do not remove an existing directory to make it pass. Confirm OS, architecture, private addresses, time synchronization and free space; allow at least 2GB RAM and 10GB free for this small lab, plus room for logs, seed and backups.
Both fresh hosts; Bash as existing sudo administrator.
(
set -euo pipefail
. /etc/os-release
printf '%s %s\n' "$ID" "$VERSION_ID"
uname -m
ip -br address
timedatectl status
df -h / /var
installed=$(rpm -qa --qf '%{NAME}\n')
if printf '%s\n' "$installed" | grep -Ei '^(mariadb|mysql|community-mysql)([0-9.]*)?(-server)?$' >/dev/null; then
echo 'Existing database package: STOP' >&2; exit 1
fi
for path in /var/lib/mysql /var/lib/mysql /etc/my.cnf /etc/my.cnf.d /etc/mysql /etc/mariadb /root/academy-seed /root/.my.cnf; do
if sudo test -e "$path" || sudo test -L "$path"; then echo "Existing state: $path; STOP" >&2; exit 1; fi
done
systemctl list-unit-files 'mariadb*' 'mysql*' --no-pager
sudo ss -lntp 'sport = :3306'
)
Both hosts are fresh, addresses are assigned, clocks synchronized and resources sufficient.
LET’S BUILD
Restrict the primary port before exposing it
Primary only. This panel requires an existing active firewalld zone with default-deny exposure, preserved SSH and ens18 assigned to the selected internal zone. Inspect zone target, services, rich/direct rules and upstream ACL before use: an existing broad mysql/3306 allow would defeat source restriction. Substitute your actual interface/zone before running. Add the same source/destination-specific rich rule to runtime and permanent state without reload. Do not enable/reset the firewall or open the mysql service globally. The replica needs no incoming database rule.
Primary
(
set -euo pipefail
zone=internal
sudo firewall-cmd --state
sudo firewall-cmd --get-active-zones
sudo firewall-cmd --zone="$zone" --list-all
test "$(sudo firewall-cmd --get-zone-of-interface=ens18)" = "$zone"
rule='rule family="ipv4" source address="10.20.0.11/32" destination address="10.20.0.10/32" port port="3306" protocol="tcp" accept'
sudo firewall-cmd --zone="$zone" --add-rich-rule="$rule"
sudo firewall-cmd --permanent --zone="$zone" --add-rich-rule="$rule"
sudo firewall-cmd --zone="$zone" --list-rich-rules
sudo firewall-cmd --permanent --zone="$zone" --list-rich-rules
)
Active default-deny firewall; only the replica can reach the primary private3306 port.
LET’S BUILD
Install this release’s signed packages
On both disposable VMs, inspect enabled repositories and select only the vendor 10.11 stream documented here. RPM uses its packaged systemd preparation to initialize a fresh datadir on first start; do not run the Arch manual initialization step. Before starting, create z0-academy-loopback.cnf for a loopback-only listener. The later role file zz-academy-replication.cnf sorts after ordinary vendor files and this bootstrap include. Do not change an existing module stream, service or database.
RHEL 10.2, standard current AppStream, not EUS: this guide selects MariaDB 10.11. On 9 use module mariadb:10.11/server; on 10 use mariadb-server (11.8 has a different package name). RHEL requires existing BaseOS/AppStream entitlement; Rocky/Alma use their own signed BaseOS/AppStream mirrors. Do not mix vendor or MariaDB upstream repositories. Service mariadb, mysql user/group, /usr/libexec/mariadbd, include /etc/my.cnf.d and datadir /var/lib/mysql. Verify the selected stream exists on both VMs; stop rather than substitute another series.
Both fresh hosts; Bash as existing sudo administrator.
(
set -euo pipefail
sudo dnf repolist --enabled
sudo dnf info mariadb-server
sudo dnf install -y mariadb-server mariadb
sudo dnf install -y openssl ca-certificates nano policycoreutils
rpm -q mariadb-server mariadb
sudo bash -eu <<'LOOPBACK'
set -o noclobber
test -d /etc/my.cnf.d
test ! -L /etc/my.cnf.d
umask 022
cat > /etc/my.cnf.d/z0-academy-loopback.cnf <<'CONFIG'
[mariadb]
bind_address=127.0.0.1
CONFIG
chmod 0644 /etc/my.cnf.d/z0-academy-loopback.cnf
LOOPBACK
sudo restorecon -v /etc/my.cnf.d/z0-academy-loopback.cnf
sudo /usr/libexec/mariadbd --verbose --help >/dev/null
sudo systemctl enable --now mariadb
sudo mariadb -NBe 'SELECT VERSION();'
sudo ss -lntp 'sport = :3306'
)
Same supported series and exact package version on both hosts; initial3306 is loopback only.
Provide an existing private-CA server certificate
Before the next commands, your PKI administrator must deliver ca.pem, primary-fullchain.pem and primary-key.pem into a root-only academy-pki directory on the primary. The leaf is for serverAuth, valid now, with SAN DNS:db-primary.example.internal and its matching unencrypted service key; the fullchain includes intermediates. Keep the CA signing key offline and out of BOTH database hosts. Deliver the SAME public CA chain as ca.pem on the replica. Certificate issuance/renewal is an existing PKI responsibility, not a self-signed certificate bypass. Verify fingerprints through a trusted channel. Do not proceed with missing, expired or mismatched files.