High availability for Tomcat keeps a Java application reachable during node failure by moving the service endpoint to a healthy cluster member.

On a Pacemaker cluster managed with pcs, the endpoint is commonly a floating IP (VIP) provided by the IPaddr2 OCF agent, while a systemd resource starts and monitors the Tomcat service unit. Grouping the resources keeps ordering predictable, so the VIP comes up before the application starts.

A VIP-based design is active/passive, meaning only one node serves traffic at a time. Application binaries and configuration must match across nodes, and session state or writable data should live outside local disks (database, shared storage, or explicit session replication) to avoid losing state during failover.

Steps to set up Tomcat high availability with PCS:

  1. Confirm the cluster is online with quorum.
    $ 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
      * 3 nodes configured
      * 0 resource instances configured
    ##### snipped #####
  2. Identify the Tomcat service unit name.
    $ systemctl list-unit-files --type=service | grep -E '^tomcat.*\.service'
    tomcat10.service                             enabled         enabled
  3. Disable the Tomcat unit autostart with an immediate stop on every cluster node.
    $ sudo systemctl disable --now tomcat10
    Removed "/etc/systemd/system/multi-user.target.wants/tomcat10.service".
    ##### snipped #####

    Stopping Tomcat outside PCS control interrupts service until the resource group starts on an active node.

  4. Create a floating IP resource for the application endpoint.
    $ sudo pcs resource create tomcat_ip ocf:heartbeat:IPaddr2 ip=192.0.2.61 cidr_netmask=24 op monitor interval=30s

    Use an unused IP on the target subnet to avoid address conflicts and intermittent traffic loss.

  5. Create the Tomcat service resource.
    $ sudo pcs resource create tomcat_service systemd:tomcat10 op monitor interval=30s

    Use the systemd unit base name (tomcat10 from tomcat10.service) in the systemd: resource identifier.

  6. Group the IP resource with the Tomcat service resource.
    $ sudo pcs resource group add tomcat-stack tomcat_ip tomcat_service

    Pacemaker starts grouped resources in listed order, so the VIP becomes available before the Tomcat unit is started.

  7. Verify the resource group placement.
    $ sudo pcs status resources
      * Resource Group: tomcat-stack:
        * tomcat_ip	(ocf:heartbeat:IPaddr2):	 Started node-01
        * tomcat_service	(systemd:tomcat10):	 Started node-01
  8. Confirm VIP reachability using an address listing plus an HTTP request to the endpoint.
    $ ip -brief address show | grep -F '192.0.2.61'
    eth0@if456       UP             192.0.2.11/24 192.0.2.61/24
    
    $ curl -I http://192.0.2.61:8080/
    HTTP/1.1 200 
    Accept-Ranges: bytes
    ETag: W/"1905-1767248950263"
    Last-Modified: Thu, 01 Jan 2026 06:29:10 GMT
    Content-Type: text/html
    Content-Length: 1905
    Date: Thu, 01 Jan 2026 06:34:49 GMT

    Set the port to the connector exposed by Tomcat, such as 8080, or the fronting proxy port when the VIP points at a reverse proxy.

  9. Run a failover test with the group in a running state.