Galera Cluster is a contemporary multi-master database cluster that is designed keeping in mind the contemporary replication, MySQL (or MariaDB), and InnoDB. It is used to direct read and write databases to any node. An individual node can be lost if the operation is uninterrupted and when the complex failover procedures are not being used. How Does MariaDB Galera Cluster Work?
Galera Cluster is only available on Linux and supports the InnoDB storage engine. It consists of the database server that uses the Galera Replication Plugins to direct replication efficiently. MariaDB replication plugin API is extended to deliver all the information and secure necessary for true multi-master, synchronous replication. This extended API is known as Write-Set Replication API (or wsrep).
This API enables MariaDB Galera Cluster to deliver certification-based replication. It consists of database rows to replicate and the information related to the entire locks held by the database during the transaction. Then, in the applier queue, each node certifies the replicated write-set against another write-set. This write-set is applied to the conflicting locks that are not required. Now, the transaction is considered committed. Later, each of these nodes continues to apply it to the tablespace.
Prior to MariaDB 10.1, the Galera cluster feature is bundled into MariaDB. So you will need to install the MariaDB server package on all three nodes. You can install it using the following command:
apt-get install mariadb-server -y
Once the MariaDB has been installed, start the MariaDB service on all nodes:
systemctl start mariadb
You can now check the status of the MariaDB with the following command:
systemctl status mariadb
You should see the following output:
● mariadb.service - MariaDB 10.3.31 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2021-10-02 03:37:11 UTC; 20s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 1803 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 31 (limit: 2353)
Memory: 66.0M
CGroup: /system.slice/mariadb.service
└─1803 /usr/sbin/mysqld
Next, you will need to secure the MariaDB installation and set a MariaDB root password on all nodes. You can do it by running the following script:
mysql_secure_installation
Answer all the questions as shown below:
Enter current password for root (enter for none):
Switch to unix_socket authentication [Y/n] n
Change the root password? [Y/n] Y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
Configuring Galera Cluster
Next, you will need to create a MariaDB Galera configuration file on each node. You can create a file in the /etc/mysql/conf.d directory.
Configuring the First Node
Login to the first node and create a MariaDB Galera configuration file:
In the above guide, we explained how to set up three nodes MariaDB cluster on Ubuntu 20.04. Now, data modifications on any node are replicated to all other nodes. You can now add more MariaDB nodes to increase the size of the cluster.
I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.
11vote
Article Rating
Subscribe
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.
DisagreeAgree
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.