Introduction
There are many forms of high availability, replication, and resilience in the face of various types of failure. For example, you can make the MariaDB Server work in an active/passive setup, such that the passive node can recover persistent messages written to the disk on the active node should the active node fail.
While this is supported clustering is intended to facilitate scalability. Cluster if a node fails queues on the failed node are lost. However, with the high availability setup described in this tutorial. When a node fails, the durable persistent messages can be recovered by a different node.
Setup MariaDB Server to all nodes
Install MySQL using dnf
# dnf install mariadb-server -y
Setup and install pcs packages for MariaDB Server
Install required packages for HA to all nodes
# dnf install pacemaker pcs resource-agents -y
Set firewall rules to allow connection
Enable port for HA connection
# firewall-cmd --permanent --add-port=7788/tcp
# firewall-cmd --permanent --add-service=high-availability
# firewall-cmd --reload
Setup authentication for all nodes
Follow commands below for reference
# pcs host auth node1 node2 node3 -u hacluster
Start the cluster
Start the cluster
# pcs cluster start --all
Enable cluster
# pcs cluster enable --all
Check status of the cluster
Disable stonith and quorum
# pcs property set stonith-enabled=false
# pcs property set no-quorum-policy=ignore
Setup DRBD
All steps are in this DRBD tutorial.
Setup Cluster resources MariaDB Server
Commands below setup cluster resources
# pcs cluster cib fs_cfg
# pcs -f fs_cfg resource create mysqldrbd \
ocf:linbit:drbd drbd_resource=drbd0 op monitor interval=30s
# pcs -f fs_cfg resource promotable mysqldrbd \
promoted-max=1 promoted-node-max=1 clone-max=2 clone-node-max=1 notify=true
Setup DRBD resource
This will create a resource cluster
# pcs resource update mysql_service ocf:heartbeat:mysql binary="/usr/bin/mysqld_safe" \
config="/etc/my.cnf" datadir="/var/lib/mysql" pid="/run/mariadb/mariadb.pid" \
socket="/var/lib/mysql/mysql.sock" additional_parameters="--bind-address=0.0.0.0" \
op start timeout=60s op stop timeout=60s op monitor interval=20s timeout=30s
Test failover of the cluster MariaDB Server
Test cluster with the command below.
# pcs cluster standby node2
Status of cluster after failover MariaDB Server resource
Check if the node has been failed over
Conclusion
DRBD is the block-level synchronous replication by the kernel module. Data can adjust the synchronization level here. Because DRBD uses the network card for block replication, for transmission, data can effectively process high concurrency. This is a type of replication and storage. It is nothing more like a hot standby machine; rather than a storage HA, it is better to ensure data security. Read more about drbd linbit.