
What Galera Cluster is, why you would use it, and the cluster we will build on real Ubuntu 24.04 servers: three MariaDB 11.4 nodes that all accept writes, a fourth node we add and remove, and an HAProxy load balancer in front.
Why we keep copies of a database (availability, read scaling, disaster recovery), and the four ACID guarantees every copy must respect: atomicity, consistency, isolation and durability, each shown with an animated example.
Who is allowed to take the writes. Master/slave (primary/replica) replication with one writer and read-only copies, failover and its risks, then multi-master replication where every node accepts writes, and the conflicts that creates.
When is a change sent to the other nodes, and when does the client hear OK? Asynchronous replication and its lost transactions, fully synchronous replication and its cost, semi-synchronous replication, and where Galera's virtually synchronous replication fits.
What exactly travels to the other nodes: the SQL statement, or the changed rows. Why non-deterministic statements break statement-based replication, and why Galera always replicates rows.
How Galera replicates a transaction: group communication that gives every node the same global order, write-sets that carry the changed rows and their keys, and the life of a transaction from the local node to commit everywhere.
One transaction certified on every node, then two conflicting transactions on two nodes at the same time: the same deterministic test on every node, the first committer wins, and the other transaction gets a deadlock error.
What a transaction is allowed to see: dirty reads, non-repeatable reads and phantom reads, the four SQL isolation levels from READ UNCOMMITTED to SERIALIZABLE, and what Galera supports across the cluster.
Two writers read the same row and both write it back: one update is silently lost. How SELECT ... FOR UPDATE prevents it on one server, and how Galera's certification behaves when the two writers are on different nodes.
How a joining node gets the data. Full state snapshot transfer (SST) with mariabackup or rsync, donor and joiner, the incremental state transfer (IST) that only sends missing write-sets, and the gcache that makes IST possible.
What your tables and your application must respect: InnoDB only, a primary key on every table, transaction size limits, explicit locks, the cost of large DDL changes, and why the cluster is only as fast as its slowest node.
Hands-on lab: the lab layout on AWS (three Ubuntu 24.04 servers in one private network), host names, name resolution with the hosts file, and the four ports Galera needs (3306, 4567, 4568, 4444).
The attached file lists every command run in this lecture, in order and grouped by server, plus the configuration files shown on screen.
Hands-on lab: add the official MariaDB 11.4 repository with the mariadb_repo_setup script, install mariadb-server and mariadb-backup on all three nodes, run the first checks, and see why the fresh install is already secure.
The attached file lists every command run in this lecture, in order and grouped by server, plus the configuration files shown on screen.
Hands-on lab: where MariaDB reads its settings, the backup user for state transfers, and every line of the Galera configuration file (wsrep_on, provider, cluster address, node name and address, SST method, binlog format, InnoDB settings).
The attached file lists every command run in this lecture, in order and grouped by server, plus the configuration files shown on screen.
Hands-on lab: bootstrap the first node with galera_new_cluster, join the other two nodes, check the cluster size and status variables, and test multi-master replication by writing on every node.
The attached file lists every command run in this lecture, in order and grouped by server, plus the configuration files shown on screen.
Hands-on lab: stop one node cleanly, keep writing on the others, then start it again and watch it catch up with an incremental state transfer (IST) from the gcache.
The attached file lists every command run in this lecture, in order and grouped by server, plus the configuration files shown on screen.
Hands-on lab: kill a node without warning. How the others detect the dead node and keep the Primary Component, what the crashed node's state file says, and how it recovers when it comes back.
The attached file lists every command run in this lecture, in order and grouped by server, plus the configuration files shown on screen.
Hands-on lab: shut down every node, then bring the cluster back. Read grastate.dat on each node, find the most advanced node with seqno and safe_to_bootstrap, bootstrap it, and join the others.
The attached file lists every command run in this lecture, in order and grouped by server, plus the configuration files shown on screen.
Hands-on lab: prepare a fourth server, install MariaDB, write its Galera configuration, update the cluster address on the other nodes, and watch it join with a full state transfer (SST) using mariabackup.
The attached file lists every command run in this lecture, in order and grouped by server, plus the configuration files shown on screen.
Hands-on lab: remove the fourth node cleanly: stop it, disable the service so it never rejoins by itself, and clean the cluster address on the remaining nodes.
The attached file lists every command run in this lecture, in order and grouped by server, plus the configuration files shown on screen.
What happens when the network splits the cluster: split brain, quorum and the Primary Component, why the minority side stops taking writes, and why an odd number of nodes protects you.
Hands-on lab: split the cluster on purpose with iptables and watch quorum decide, change node weights with wsrep_provider_pc_weight, and add the Galera arbitrator (garbd) as a voting member that stores no data.
The attached file lists every command run in this lecture, in order and grouped by server, plus the configuration files shown on screen.
How applications reach a Galera cluster: connecting to one node directly, a driver with a list of nodes, a TCP load balancer such as HAProxy, or a database-aware proxy, with the strengths and limits of each.
Hands-on lab: install HAProxy 2.8 on a proxy server, create a health-check user, write the frontend and backend for the three Galera nodes, test round robin, watch failover when a node stops, then why the proxy becomes a new single point of failure and how a second proxy with Keepalived and a virtual IP removes it.
The attached file lists every command run in this lecture, in order and grouped by server, plus the configuration files shown on screen.
Hands-on lab: restrict the Galera ports with a firewall (ufw), check encrypted client connections (TLS 1.3 by default), and encrypt replication traffic between nodes with certificates in wsrep_provider_options.
The attached file lists every command run in this lecture, in order and grouped by server, plus the configuration files shown on screen.
Hands-on lab: check cluster health in four wsrep status variables (cluster status, cluster size, local state, ready), understand flow control and the receive queue, read the conflict counters, and decide what to alert on.
The attached file lists every command run in this lecture, in order and grouped by server, plus the configuration files shown on screen.
A recap of everything you can now do with Galera Cluster, from replication theory to building, operating, securing and monitoring a multi-master MariaDB cluster.
In this course the students will learn many topics about database replication, this course includes learning theoretical concepts and practical tasks. In this course the students will learn about the following topics:
Database Replication
Synchronous and Asynchronous Replication
Statement Based Replication and Row Based Replication
Group Communications, Write Sets and Certification Based Replication
Building 3 nodes Galera Cluster (Practical)
Testing Potential Nodes Failures (Practical)
Joining New Nodes to The Cluster (Practical)
Weighted Quorum Concepts
Load Balancing
Checking The Cluster Status
Eventually, this will be a continuous course I am going to add any additional topics I think they are important, and any topics requested by students.
So, if you think that this course can be improved by adding any topics, then please let me know.