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:

  1. 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 #####
  2. 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.

  3. 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           -
  4. 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.

  5. 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.

  6. Verify the cloned resource status.
    $ sudo pcs status resources
    ##### snipped #####
      * Clone Set: mysql_service-clone [mysql_service]:
        * Started: [ node-01 node-02 node-03 ]
  7. Update client routing to distribute traffic across active nodes.
  8. Run a failover test to confirm routing and writes survive a node outage.