In MariaDB Cluster, the Server replicates a transaction at commit time by broadcasting the write set associated with the transaction to every node in the cluster. The client connects directly to the DBMS and experiences behavior that is similar to native MariaDB in most cases. The wsrep API (write set replication API) defines the interface between Galera replication and MariaDB.Galera’s replication is not completely synchronous. It is sometimes called virtually synchronous replication. Galera replication is a highly transparent, scalable, and virtually synchronous replication solution for database clustering to achieve high availability and improved performance.
You can check the official site Maria-db Galera site here.
Here;s example how to configure.
- Install MariaDB server and Galera replication package on each server:
sudo apt-get update
sudo apt-get install mariadb-server galera-4
- Configure MariaDB server for Galera replication:
sudo nano /etc/mysql/conf.d/galera.cnf
Add the following lines to the file:
makefileCopy code[galera]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera-4/libgalera_smm.so
# Galera Cluster Configuration
wsrep_cluster_name="my_galera_cluster"
wsrep_cluster_address="gcomm://ip1,ip2,ip3"
# Galera Synchronization Configuration
wsrep_sst_method=rsync
Note: Replace “ip1,ip2,ip3” with the IP addresses of your Galera cluster nodes.
- Start the MariaDB service on the node at ip1
sudo systemctl start mariadb
- Secure the MariaDB installation:
sudo mysql_secure_installation
- Test the Galera replication by creating a sample database on one node and checking if it is replicated to the other nodes:
mysql -u root -p
CREATE DATABASE testdb;
On another node, check if the “testdb” database is replicated:
mysql -u root -p -e "SHOW DATABASES;"
You now have MariaDB Galera replication configured and running on your Ubuntu 22.04 server. You can add more nodes to the Galera cluster by repeating steps 1-5 on each node, and updating the “wsrep_cluster_address” parameter in step 2 to include the new nodes.