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.
Related: How to set up Tomcat active-active with PCS
Related: How to create a Pacemaker cluster
Steps to set up Tomcat high availability with PCS:
- 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 #####
- Identify the Tomcat service unit name.
$ systemctl list-unit-files --type=service | grep -E '^tomcat.*\.service' tomcat10.service enabled enabled
- 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.
- 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.
- 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.
- 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.
- 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 - 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.
- Run a failover test with the group in a running state.
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.
