Running MySQL or MariaDB in an active-active design keeps database access available when a node fails and supports spreading client connections across multiple hosts instead of a single primary.
In a Pacemaker and Corosync cluster, the pcs CLI defines resources that the cluster manager starts, stops, and monitors. A systemd resource that targets mariadb.service, mysql.service, or mysqld.service can be cloned so each cluster node runs the service while Pacemaker continuously checks health and performs recovery actions.
Active-active service management only works when the database layer is already multi-writer (for example, a Galera-based cluster), because cloning a standalone MySQL instance creates independent datasets. Quorum and fencing (STONITH) reduce split-brain risk, and client routing should avoid nodes that are not synced or not ready to accept writes.
Steps to set up MySQL or MariaDB active-active with PCS:
- Confirm the cluster is online and has quorum.
$ sudo pcs status Cluster name: clustername Cluster Summary: * Stack: corosync (Pacemaker is running) * Current DC: node-02 (version 2.1.6-6fdc9deea29) - partition with quorum * 3 nodes configured * 5 resource instances configured Node List: * Online: [ node-01 node-02 node-03 ] ##### snipped #####
- Confirm the database replication layer reports a healthy multi-writer state on each node.
$ sudo mysql -Nse "SHOW STATUS LIKE 'wsrep_cluster_status';" wsrep_cluster_status Primary $ sudo mysql -Nse "SHOW STATUS LIKE 'wsrep_ready';" wsrep_ready ON $ sudo mysql -Nse "SHOW STATUS LIKE 'wsrep_cluster_size';" wsrep_cluster_size 3
The wsrep_ checks apply to Galera-based clusters and should return Primary and ON before traffic distribution.
- Identify the MySQL or MariaDB service unit name.
$ systemctl list-unit-files --type=service | grep -E '^(mysql|mysqld|mariadb)\.service' mariadb.service disabled enabled mysql.service alias - mysqld.service alias -
- Create the MySQL or MariaDB service resource.
$ sudo pcs resource create mysql_service systemd:mariadb op monitor interval=30s
Use systemd:mysqld or systemd:mysql when that unit is present.
Related: How to create a Pacemaker resource
- Clone the MySQL or MariaDB service resource across nodes.
$ sudo pcs resource clone mysql_service
Cloning starts the service on every eligible node. Ensure multi-writer replication is healthy. Ensure client routing is not yet sending production writes to unsynced nodes.
- Verify the cloned resource status.
$ sudo pcs status resources ##### snipped ##### * Clone Set: mysql_service-clone [mysql_service]: * Started: [ node-01 node-02 node-03 ] - Update client routing to distribute traffic across active nodes.
- Run a failover test to confirm routing and writes survive a node outage.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
