// Replication

MariaDB Replication & Galera

ตั้งค่า Replication ของ MariaDB — Master-Slave, GTID-based, Galera Multi-Master และ Semi-sync

// Replication Types

ประเภท Replication

➡️
Async Replication
Classic Master-Slave — master ไม่รอ slave confirm รวดเร็ว แต่อาจ lag ได้ เหมาะสำหรับ read scaling
🔄
Semi-Sync Replication
Master รอ slave อย่างน้อย 1 ตัว confirm ก่อน commit — ลด data loss risk สำหรับ critical data
🌐
Galera Cluster
Synchronous multi-master — ทุก node sync กันทันที เหมาะสำหรับ HA ที่ไม่ยอมรับ data loss
// GTID Setup

GTID-based Replication

# Master config (my.cnf) server_id = 1 log_bin = mysql-bin binlog_format = ROW gtid_strict_mode = ON # Slave config (my.cnf) server_id = 2 log_bin = mysql-bin log_slave_updates = ON gtid_strict_mode = ON -- Setup slave (MariaDB GTID syntax) CHANGE MASTER TO MASTER_HOST="192.168.1.10", MASTER_USER="repl", MASTER_PASSWORD="replpass", MASTER_USE_GTID=slave_pos; START SLAVE; SHOW SLAVE STATUS\G