High Availability

MySQL Group Replication: Single-Primary Cluster Setup

Configure MySQL Group Replication (MGR) with Paxos-based consensus for fault-tolerant clustering. Covers prerequisites, bootstrap, joining nodes, and health monitoring.

JusDB Team
March 14, 2025
5 min read
195 views

MySQL Group Replication (MGR) provides a fault-tolerant, multi-primary or single-primary cluster using Paxos-based distributed consensus. It is the foundation for MySQL InnoDB Cluster.

Single-Primary vs Multi-Primary

  • Single-primary: One writable primary, automatic failover — simpler, recommended for most workloads
  • Multi-primary: All nodes accept writes — complex conflict detection, avoid unless needed

Prerequisites

  • All nodes: MySQL 8.0+, GTID enabled, row-based replication
  • All nodes must have unique server_id and server_uuid
  • Firewall: open port 33061 (group communication port)

my.cnf Configuration (Each Node)

ini
[mysqld]
server_id = 1  # unique per node
gtid_mode = ON
enforce_gtid_consistency = ON
binlog_format = ROW
log_replica_updates = ON
plugin_load_add = group_replication.so
group_replication_group_name = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
group_replication_start_on_boot = OFF
group_replication_local_address = '10.0.1.10:33061'
group_replication_group_seeds = '10.0.1.10:33061,10.0.1.11:33061,10.0.1.12:33061'
group_replication_bootstrap_group = OFF

Bootstrap the First Node

sql
-- On node1 only, once
SET GLOBAL group_replication_bootstrap_group = ON;
START GROUP_REPLICATION;
SET GLOBAL group_replication_bootstrap_group = OFF;

Join Additional Nodes

sql
-- On node2 and node3
CHANGE MASTER TO MASTER_USER='replication_user', MASTER_PASSWORD='password'
  FOR CHANNEL 'group_replication_recovery';
START GROUP_REPLICATION;

Check Group Status

sql
SELECT MEMBER_ID, MEMBER_HOST, MEMBER_PORT, MEMBER_STATE, MEMBER_ROLE
FROM performance_schema.replication_group_members;

Key Takeaways

  • Use single-primary mode unless you have a specific multi-primary use case
  • GTID and row-based replication are mandatory prerequisites
  • Bootstrap (group_replication_bootstrap_group = ON) only on the first node, only once
  • Monitor replication_group_members for node state and role

JusDB Can Help

MySQL Group Replication has complex failure modes. JusDB can design and support your MGR or InnoDB Cluster deployment.

Share this article

JusDB Team

Official JusDB content team