High availability for a MySQL or MariaDB endpoint reduces downtime by keeping the database service and its client-facing address together during node failure or maintenance. Applications continue using the same host or IP while the cluster relocates the active instance.
The pcs CLI configures Pacemaker resources for a floating IP plus the database daemon. An ocf:heartbeat:IPaddr2 resource adds the floating address, a systemd resource controls the database unit, and a resource group enforces colocation and ordered start/stop so the IP exists before the daemon starts.
Failover moves the service and address; it does not replicate database data. Ensure the storage or replication design keeps the data directory consistent across nodes, and enable fencing to prevent split-brain. Planned failover tests should occur during a maintenance window because active sessions drop during stop/start.
$ sudo pcs status Cluster name: clustername Cluster Summary: * Stack: corosync (Pacemaker is running) * Current DC: node-01 (version 2.1.6-6fdc9deea29) - partition with quorum * Last updated: Thu Jan 1 05:39:07 2026 on node-01 * Last change: Thu Jan 1 05:39:05 2026 by root via cibadmin on node-01 * 3 nodes configured * 0 resource instances configured Node List: * Online: [ node-01 node-02 node-03 ] Full List of Resources: * No resources Daemon Status: corosync: active/enabled pacemaker: active/enabled pcsd: active/enabled
$ systemctl list-unit-files --type=service | grep -E '^(mysql|mysqld|mariadb)\.service' mariadb.service disabled enabled mysql.service alias - mysqld.service alias -
$ sudo systemctl disable --now mariadb Synchronizing state of mariadb.service with SysV service script with /usr/lib/systemd/systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install disable mariadb Synchronizing state of mariadb.service with SysV service script with /usr/lib/systemd/systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install disable mariadb Synchronizing state of mariadb.service with SysV service script with /usr/lib/systemd/systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install disable mariadb
Stopping the database service interrupts active connections.
$ sudo pcs resource create db_ip ocf:heartbeat:IPaddr2 ip=192.0.2.20 cidr_netmask=24 op monitor interval=30s
Set nic=<interface> when multiple network interfaces exist.
$ sudo pcs resource create db_service systemd:mariadb op start timeout=120s op stop timeout=120s op monitor interval=30s
Use systemd:mysqld or systemd:mysql when those units are present.
$ sudo pcs resource group add db-stack db_ip db_service
$ sudo pcs status resources
* Resource Group: db-stack:
* db_ip (ocf:heartbeat:IPaddr2): Started node-01
* db_service (systemd:mariadb): Started node-01
$ ip -brief address show lo UNKNOWN 127.0.0.1/8 ::1/128 ##### snipped ##### eth0@if456 UP 192.0.2.11/24 192.0.2.20/24
$ sudo ss --tcp --listening --numeric --processes
State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0 80 0.0.0.0:3306 0.0.0.0:* users:(("mariadbd",pid=196578,fd=24))
##### snipped #####