Galera Cluster
Galera Cluster is a synchronous, multi-primary clustering solution for MariaDB and MySQL-compatible databases. It allows multiple database servers to maintain copies of the same data, with transactions replicated between nodes and consistency checks before a transaction is committed.
It is useful when you need high availability, database redundancy, and the ability to serve database requests from multiple servers.
How Galera Cluster works
Application servers
PHP · C++ · Java · REST APIs
Node 2
MariaDB
Replica copy
Node 3
MariaDB
Replica copy
Galera replication
Transaction ordering · Certification · Cluster membership
Each node contains the database data. Applications can read and write to any node, subject to transaction certification, conflict handling, and cluster state.
Key features
High availability: If one database node fails, the remaining nodes can continue serving requests when the cluster retains quorum.
Synchronous-style replication: Galera uses virtually synchronous replication and transaction certification to keep nodes consistent.
Multi-primary operation: Applications can write to any healthy node.
Automatic node recovery: A returning node can catch up using incremental state transfer or, when necessary, a full state transfer.
No single database master: There is no permanently designated primary node in the normal multi-primary configuration.
Galera versus ordinary replication
Feature | Galera Cluster | Traditional primary-replica |
|---|
Writes | Any node | Usually primary only |
Replication | Virtually synchronous | Commonly asynchronous |
Failover | Cluster membership and quorum | Often requires promotion |
Write conflicts | Certification can reject conflicting transactions | Usually handled at the primary |
Network latency | Affects write performance | Often less impact on primary commits |
Complexity | Higher | Generally lower |
Recommended three-server configuration
Server 1 — Jacksonville
MariaDB + Galera
Server 2 — Separate location
MariaDB + Galera
Server 3 — Separate failure domain
MariaDB + Galera
Three voting members are a common production design because the cluster can retain a majority if one node fails. For best performance, keep nodes on a low-latency network; geographically dispersed nodes can introduce significant write latency.
Important: Galera does not replace backups. It also does not automatically provide application load balancing. A proxy such as HAProxy or ProxySQL can direct database connections to healthy nodes.
When should you use Galera?
For your MariaDB-based applications, Galera is worth considering when database downtime is unacceptable and you need redundant database servers. If you only have one physical server, installing virtualization or running multiple database instances on that same machine will not provide equivalent hardware-failure protection.
Official resources: