mariadb-impl-replication-setup
Installation
SKILL.md
MariaDB Replication Setup
Deterministic patterns for primary-replica replication: async baseline, semi-sync, parallel applier, GTID, and multi-source named connections. Skill covers MariaDB 10.6-LTS, 10.11-LTS, 11.x, 12.x.
Quick Reference
- ALWAYS set a UNIQUE
server_id(1 to 2^32-1) on every node before enablinglog_bin. Two nodes with the sameserver_idsilently corrupt replication. - ALWAYS use
binlog_format=MIXED(default since 10.2.4) orROW. NEVER useSTATEMENTalone with non-deterministic functions (UUID(),NOW(6),LIMITwithoutORDER BY,SLEEP, user-defined functions). - Semi-sync is BUILT-IN from MariaDB 10.3+. NEVER run
INSTALL PLUGIN rpl_semi_sync_master. Just setrpl_semi_sync_master_enabled=ONon the primary andrpl_semi_sync_slave_enabled=ONon the replica. - On
rpl_semi_sync_master_timeout(default 10000 ms) the primary falls back to async and logs a warning. When a replica catches up, semi-sync resumes automatically. Apparent "hangs" under load are usually this timeout being too low. slave_parallel_mode=optimisticis the DEFAULT from 10.5.1+. Earlier versions default toconservative. Both primary and replica must be 10.0.5+ for any parallel mode.- Start
slave_parallel_threadsat 4-8 and TUNE based on actual disk-IO benchmark on the replica. NEVER set above 16 without proof it helps. - MariaDB GTID format is
domain-server-sequence(e.g.0-1-1234). MySQL GTID isuuid:seqno. They are INCOMPATIBLE. MariaDB can replicate FROM a MySQL primary, but MySQL CANNOT replicate from a MariaDB primary. For two-way or MariaDB-to-MySQL: dump-and-load, not GTID. - Multi-source uses NAMED CONNECTIONS:
CHANGE MASTER 'channel_name' TO .... NEVER use MySQLFOR CHANNELsyntax: it returns a syntax error. SHOW SLAVE STATUS(single source) orSHOW ALL SLAVES STATUS(multi-source, 10.0+). Replica aliasesSHOW REPLICA STATUSexist from 10.5+. BothSlave_IO_RunningandSlave_SQL_RunningMUST beYes.- Replication user privileges:
REPLICATION SLAVE(mandatory) +REPLICATION CLIENT(recommended, forSHOW MASTER STATUS).