MariaDB Galera
MariaDB Galera is a high-availability deployment model built on Galera replication. dbdeployer supports it with the galera topology.
5-Minute Tutorial
Section titled “5-Minute Tutorial”This example uses MariaDB 10.11. Use a MariaDB tarball that includes Galera support.
1. Install Runtime Tools
Section titled “1. Install Runtime Tools”MariaDB Galera deployments run only on Linux. The host must have socat, rsync, and the usual MariaDB shared-library dependencies available.
sudo apt-get updatesudo apt-get install -y libaio1 libnuma1 libncurses5 socat rsyncSome older MariaDB tarballs may also require legacy OpenSSL libraries on newer Linux distributions.
2. Unpack a MariaDB Tarball
Section titled “2. Unpack a MariaDB Tarball”dbdeployer unpack mariadb-10.11.21-linux-systemd-x86_64.tar.gzdbdeployer versions# 10.11.21If the tarball does not contain Galera libraries, --topology=galera is rejected.
3. Deploy the Cluster
Section titled “3. Deploy the Cluster”dbdeployer deploy replication 10.11.21 --topology=galeraThe default deployment creates three writable Galera nodes:
~/sandboxes/galera_msb_10_11_21/├── node1/├── node2/├── node3/├── check_nodes├── start_all├── stop_all└── use_all4. Check Cluster Health
Section titled “4. Check Cluster Health”~/sandboxes/galera_msb_10_11_21/check_nodesEach node should report a cluster size of 3 and a synced local state.
5. Verify Writes Replicate
Section titled “5. Verify Writes Replicate”Write on one node and read from another:
~/sandboxes/galera_msb_10_11_21/n1 -e "CREATE DATABASE galera_demo"~/sandboxes/galera_msb_10_11_21/n1 -e "CREATE TABLE galera_demo.t1(id INT PRIMARY KEY, val VARCHAR(50))"~/sandboxes/galera_msb_10_11_21/n1 -e "INSERT INTO galera_demo.t1 VALUES (1, 'galera works')"~/sandboxes/galera_msb_10_11_21/n3 -e "SELECT * FROM galera_demo.t1"ProxySQL Tutorial
Section titled “ProxySQL Tutorial”Add --with-proxysql when deploying the topology. proxysql must be in PATH.
dbdeployer deploy replication 10.11.21 --topology=galera --with-proxysqlCheck that ProxySQL has all three MariaDB Galera nodes registered:
~/sandboxes/galera_msb_10_11_21/proxysql/use -e "SELECT hostgroup_id, hostname, port FROM mysql_servers"Run a query through ProxySQL:
~/sandboxes/galera_msb_10_11_21/proxysql/use_proxy -e "SELECT @@port"Cleanup
Section titled “Cleanup”dbdeployer delete galera_msb_10_11_21 --skip-confirmReference
Section titled “Reference”MariaDB Galera requires a MariaDB tarball that includes the Galera library and wsrep support.
dbdeployer deploy replication 10.11.21 --topology=galeraThe generated sandbox directory is ~/sandboxes/galera_msb_<version>/, where dots in the version are converted to underscores.
Generated scripts include:
start_allandstop_allto control the whole clustercheck_nodesto inspect wsrep cluster stateuse_allto run a query on every noden1,n2, andn3shortcuts for individual nodes
Galera topology requires at least three nodes. Options that make nodes read-only are rejected because Galera topologies are designed as writable clusters.
How It Works
Section titled “How It Works”Galera uses synchronous write-set replication:
- A transaction is executed on any node.
- The write set is broadcast to the other nodes.
- All nodes certify it for conflicts.
- If it passes, the transaction commits cluster-wide.
Every node can accept writes, so dbdeployer generates a multi-node sandbox with identical access scripts on each node.