High Availability

Two Meridian nodes form an active/passive pair coordinated through their shared PostgreSQL database: one node runs all services (ACTIVE), the other waits fully installed but with services stopped (STANDBY) and promotes itself if the active node fails. All liveness decisions use the database clock; node clocks never participate.

HA pair (coordinator mode)
     Node A [ACTIVE]                      Node B [STANDBY]
  runs all services                blocked at the startup gate
  writes heartbeat ──────┐         monitors partner heartbeat ──┐
  serves /rest/ha/*      ▼                                      │
                 shared PostgreSQL  ◄───────────────────────────┘
                  ha_instance_status
         ▲
         └── /rest/ha/sync/* ────► standby pulls etc/ from active

Requirements

  • Two identically installed nodes (same version, same install path) sharing one PostgreSQL database.

  • Network access between the nodes' web ports (config sync, REST status) and from both nodes to PostgreSQL.

  • The HA feature artifacts present in the distribution (lib/ and system/).

  • A PostgreSQL max_connections large enough for both nodes at once. During every handover the old active node is still draining while the promoted node starts its services, so both hold connections for a short time. Size it as at least twice one node’s pool total (the maxPool of the opennms, opennms-admin, and opennms-monitor data sources in opennms-datasources.xml), plus superuser_reserved_connections and any other clients of the server. Running out during a handover can crash the promoted node; PostgreSQL logs it as FATAL: sorry, too many clients already.

Install the second node

Install the second node exactly as you installed the first (see Installation and Configuration), with two differences:

  • Point its $OPENNMS_HOME/etc/opennms-datasources.xml at the same database as the first node: the pair coordinates through that shared database, and neither node holds HA state locally.

  • Run $OPENNMS_HOME/bin/install -dis before the node joins the pair — ideally with the first node stopped, or during a maintenance window, since it touches the shared database. The schema is already initialized, so the run changes nothing there, but it creates the etc/configured marker; without it bin/opennms start refuses to start.

Config sync replicates only $OPENNMS_HOME/etc, so anything outside it needs to be applied to the second node by hand: systemd drop-ins (for example LimitNOFILE), OS limits, kernel tuning, and Java settings in /etc/sysconfig or /etc/default. Hand-applied tuning on the first node is easy to miss here. A node that runs out of file descriptors logs Too many open files; network sockets count against that limit, so it can appear under connection load rather than file access.

Do not hand-copy $OPENNMS_HOME/etc from the first node: config sync populates it once HA is enabled, and the per-node files (ha-configuration.xml, plus anything in <sync-excludes>) must stay local.

Enable

On each node:

  1. Activate the HA shell and REST features once:

    echo "opennms-ha-rest" | sudo tee ${OPENNMS_HOME}/etc/featuresBoot.d/ha.boot
    echo "opennms-ha-shell" | sudo tee -a ${OPENNMS_HOME}/etc/featuresBoot.d/ha.boot
  2. Edit $OPENNMS_HOME/etc/ha-configuration.xml: set enabled=true, a unique instance-id, the role (one PRIMARY, one SECONDARY), the partner’s instance-id and REST URL. Use HTTPS for partner-rest-url in production; sync transfers credential stores.

    Changes to enabled, instance-id, role, mode, or partner-rest-url take effect only on restart, and a running node rejects the whole reloaded file (including runtime-safe settings) while any of them differ from what it started with. A file that does not parse is ignored with a warning while the node runs, but stops the node from starting services at the next restart, so you may want to check it with xmllint --noout after editing.
  3. Enable HTTPS on each node if you follow that advice. Setting the org.opennms.netmgt.jetty.https-* properties in opennms.properties.d/ is not enough on its own: no HTTPS connector exists until you copy etc/examples/jetty.xml to etc/jetty.xml and uncomment its "Add HTTPS support" block. See Secure Jetty with HTTPS for the full procedure. The host name in partner-rest-url must match a name in the partner’s certificate; a URL with an IP address fails hostname verification unless the certificate lists that address as a SAN.

  4. Create the config-sync service account on the active node: add a user (see User Creation and Configuration) and assign it the ROLE_ADMIN security role. The standby authenticates to the active node with this account to pull configuration; any user name works. Creating it on one node is enough, because users.xml is itself synced.

    If you create the account through the REST API, add hashPassword=true to the request (POST /rest/users?hashPassword=true, or PUT /rest/users/<id> with password=<password>&hashPassword=true). Without it the password value is stored verbatim in users.xml, and that file is then replicated to the other node. The web UI always hashes the password.

  5. Store that password in each node’s vault so it never appears in a configuration file:

    $OPENNMS_HOME/bin/scvcli set hasync hasync <password>

    Then set <sync-username>hasync</sync-username> and <sync-password>${scv:hasync:password}</sync-password> in ha-configuration.xml on both nodes.

  6. Using systemctl edit, uncomment the lines for Restart= and RestartSec= in the shipped opennms.service systemd unit.

  7. Restart both nodes. The PRIMARY claims ACTIVE; the SECONDARY blocks before starting services and monitors the primary’s heartbeat.

States

State Meaning

ACTIVE

Runs all services; writes its heartbeat every heartbeat-interval-seconds.

STANDBY

A SECONDARY waiting to take over: alive and heartbeating, services blocked. Promotes when the PRIMARY’s state becomes non-ACTIVE or its heartbeat exceeds failover-threshold-seconds (verified twice, one interval apart). Also the state a stepped-down node publishes as it stops.

DEGRADED

A PRIMARY that started while the SECONDARY was serving: alive and heartbeating, services blocked, and it reclaims ACTIVE automatically as soon as the SECONDARY stops being ACTIVE. Both states mean "not serving"; they differ in which node is waiting and what it is waiting for.

FAILED

The node stopped while holding an active role, without a handover. Published only after its services finished stopping.

A node that cannot load its HA configuration, prove its partner’s state, or persist its own refuses to start services rather than run unsupervised.

Operate

Action How

Status

opennms:ha-status (Karaf shell) or GET /rest/ha/status

Failover (step the active down)

opennms:ha-failover --force or POST /rest/ha/failover, on the active node. Its services stop, STANDBY is published when the stop completes, and the partner promotes within one heartbeat interval. With a restart policy set the stepped-down node returns on its own and rejoins as DEGRADED, awaiting failback; otherwise start it manually. To take a node out of service for maintenance, use systemctl stop instead — a restart policy would bring a failed-over node straight back.

Failback

Start the repaired primary (it parks DEGRADED), let one sync cycle complete, then run failover on the serving secondary. The primary reclaims ACTIVE automatically.

Planned restart without failover

Stop the standby first, restart the active, start the standby again.

Change settings at runtime

Edit the file (re-read every 60 seconds), PUT /rest/ha/config, or opennms:ha-config. enabled, instance-id, role, mode, and partner-rest-url require a restart.

Failure detection: a hard failure (power loss, kill -9) leaves the row ACTIVE with an aging heartbeat; the standby promotes after failover-threshold-seconds plus one verification interval. A graceful stop publishes its terminal state after the service drain, and the partner promotes on it immediately. If both nodes ever consider themselves ACTIVE (split brain), the node that took the role earlier halts itself; arbitration only counts a partner whose heartbeat is live.

Timing and tuning

Defaults are a heartbeat every 10 seconds, a failover threshold of 60 seconds, and a config sync every 60 seconds. The minimum values are a 5-second heartbeat interval, a 20-second failover threshold, and a 5-second sync interval; the threshold must also be at least twice the heartbeat interval. Values below a minimum are raised rather than rejected, and the change is logged: a 60-second heartbeat forces the threshold to at least 120 seconds, whatever you configured.

Approximate handover times with the default settings:

Event The standby begins starting services after

Operator failover, or a graceful stop of the active node

the active node’s service drain completes, plus up to one heartbeat interval

Hard failure (power loss, kill -9, frozen host)

the failover threshold plus one verification interval — about 70 seconds

The promoted node then needs its normal service startup time before it is fully serving. Both nodes need a database round-trip well inside the heartbeat interval; node clock skew is irrelevant, since every timing decision uses the database clock.

Configuration sync

While non-ACTIVE, a node replicates etc/ from the active node every sync-interval-seconds: binary-safe (keystores, users.xml, scv.jce), hash-compared, applied atomically, with deletions propagated. ha-configuration.xml and examples/ are never synced.

On identically installed nodes leave <sync-excludes> empty; list only files that genuinely differ per node (for example a host-specific certificate store). A file excluded on either node is neither overwritten nor deleted by sync.

Client access

A non-ACTIVE node does not listen on its web port at all, because HA holds startup before the web server starts. An unauthenticated HTTP health check against the web port, such as GET /opennms/rest/health/probe, therefore tells a load balancer or reverse proxy which node is serving. The probe returns 200 only when all health checks pass (599 otherwise), so a failing check also takes the active node out of rotation; GET /opennms/login.jsp checks only that the web server is up.

Supervision modes

<mode>coordinator</mode> (default) — the node runs the HA state machine described above itself.

<mode>heartbeat-only</mode> — an external supervisor (HA agent, cluster manager) owns all decisions and the node’s only HA duty is publishing its heartbeat; startup is never gated and config sync is not run. Use this when a third-party tool manages failover.

Security notes

The /rest/ha/config, /rest/ha/failover, and /rest/ha/sync/* endpoints require ROLE_ADMIN; the sync endpoints serve raw credential stores. Because sync replicates keystores and users.xml, the two nodes form a single secret domain: protect etc/ and the sync account credential accordingly, and prefer HTTPS between the nodes.