Comparing Popular MySQL Cluster Architectures: MHA, MySQL Cluster, and Cobar
This article reviews three mainstream MySQL clustering solutions—MHA master‑slave replication, Oracle's MySQL Cluster, and Alibaba's open‑source Cobar—detailing their architectures, advantages, drawbacks, and practical deployment considerations for high availability and scalability.
Master‑Slave Replication with MHA
MHA (Master High Availability Manager and Tools for MySQL) is a Perl‑based utility that monitors a MySQL master‑slave topology, synchronizes binlog differences, and performs automatic failover. When the master crashes, MHA selects a slave (randomly or according to a priority configuration) and promotes it to become the new master, then re‑points the remaining slaves.
Read/write separation: Implemented at the application level by configuring separate connection pools for reads and writes, or by inserting an SQL proxy between the application and the database.
Read‑load balancing: Can be achieved with hardware or software load balancers such as F5, LVS, HAProxy, or any SQL‑aware proxy that supports health checks and failover. LVS is commonly recommended for its performance.
MHA manager node responsibilities:
Detect master failure via heartbeat.
Copy any missing binlog events from the failed master to the selected slave to ensure data consistency.
Promote the chosen slave to master and update the replication topology.
Official MySQL Cluster Architecture
MySQL Cluster (NDB Cluster) is Oracle’s enterprise‑grade, shared‑nothing solution that provides real‑time data replication across nodes and transparent failover. It targets 99.999 % availability.
Component roles:
MGM node: Stores configuration, controls node lifecycle, and runs backups. Its failure does not affect data availability because the cluster can operate with a standby MGM.
SQL node: Provides the MySQL client interface; queries are routed to NDB data nodes.
NDB data node: Holds the actual table data in a distributed, in‑memory/ disk‑based structure.
Load balancing: Same tools as for MHA (F5, LVS, HAProxy, SQL proxies) can distribute read/write traffic across SQL nodes.
Sharding support: Tables that require horizontal partitioning must use the NDB storage engine. The cluster automatically distributes rows across data nodes based on the configured partitioning scheme.
Cross‑data‑center replication: Row‑level synchronization enables deployment of clusters in multiple data centers with near‑real‑time consistency.
Open‑Source Distributed Solution Cobar
Cobar, developed by Alibaba, is a middleware layer that presents a single logical MySQL database while routing queries to multiple backend MySQL instances. It combines clustering, sharding, load balancing, and health‑check capabilities.
Horizontal table splitting: A single logical table can be partitioned into multiple physical tables stored on different MySQL instances.
Database‑level routing: Different logical tables may be assigned to distinct backend databases; mixed strategies (both table‑level and database‑level sharding) are common. Heartbeat monitoring: Cobar periodically pings each backend MySQL server; if a server becomes unavailable, Cobar automatically redirects traffic to a standby instance.
Core features:
Cluster management and automatic failover.
SQL parsing and result aggregation from multiple backends.
Load balancing across backend nodes.
Support for MySQL master‑master (bidirectional) replication as the underlying data‑sync mechanism.
Reference: http://blog.itpub.net/25723371/viewspace-1977389/
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
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.
