Can MySQL Group Replication Power Dual‑Active Data Centers? A Practical Test Script
This article presents a detailed design, implementation, and automated testing script that evaluates whether MySQL Group Replication can support dual‑data‑center active‑active deployments, covering deployment steps, replication modes, fault simulation, data consistency checks, and key conclusions.
Background
Many enterprises aim for dual‑data‑center active‑active deployment to improve high availability and disaster recovery, and they wonder whether MySQL Group Replication (MGR) can meet this requirement.
Design Goals
Validate that MGR can operate across two data centers with simultaneous writes, automatic data synchronization, and automatic failover.
Automate deployment, failover simulation, and data‑consistency verification to reduce manual effort and increase testing efficiency.
Main Features of the Test Script
One‑click deployment of two MGR clusters using dbdeployer, supporting both single‑primary and multi‑primary topologies.
Flexible replication link testing with configurable uni‑directional or bi‑directional channels.
Automated fault injection and recovery , including node shutdown, primary election waiting, and node re‑join.
Data consistency and replication status verification with automatic test‑data insertion and query checks.
Test Conclusions
In single‑primary mode, configuring bi‑directional replication is not recommended; instead, use MySQL Shell to deploy a ClusterSet architecture with MySQL Router for true active‑active.
When bi‑directional replication is configured in either mode, the skip_replica_start option must be enabled; otherwise, a node that restarts will attempt to sync the other cluster’s data before joining, causing GTID mismatch and preventing re‑joining.
MySQL Shell currently does not support configuring bi‑directional replication, so only InnoDB ClusterSet can be used for active‑active setups.
Usage Example
# Deploy single‑primary clusters
python mgr_test.py -s
# Deploy multi‑primary clusters
python mgr_test.py -m
# Run single‑primary uni‑directional test
python mgr_test.py -ss
# Run multi‑primary bi‑directional test
python mgr_test.py -aaScript Source (excerpt)
#!/usr/bin/env python3
from typing import List, Dict, Literal
import subprocess, time, argparse
MYSQL_VERSION = "8.0.40"
REPL_USER = "msandbox"
REPL_PASSWORD = "msandbox"
# MGR cluster port configuration
MGR1_PORTS = [4316, 4317, 4318] # first MGR cluster ports
MGR2_PORTS = [5316, 5317, 5318] # second MGR cluster ports
SANDBOX = "$HOME/workbench/sandboxs"
REPLICATION_CHANNELS = {
"mgr1": "async_mgr2_to_mgr1",
"mgr2": "async_mgr1_to_mgr2"
}
# ... (remaining class definitions and functions as in the original script) ...References
[1] MySQL Group Replication documentation: https://dev.mysql.com/doc/en/group-replication.html
[2] Cursor tool: https://www.cursor.com/
Aikesheng Open Source Community
The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
