Skip to content

High availability

An OkYouIn cluster is two complete OkYouIn servers and a small witness. Both servers answer sign-ins at the same time; if one fails, the other carries on, and the database fails over to it automatically within seconds. High availability is included in every license — nodes are not counted.

  • Two database nodes. Each is a full OkYouIn server: console, RADIUS, SSO (OIDC, SAML, Kerberos), Web Push and the Windows agent API.
  • One witness. A third, small machine that runs only the cluster’s coordination service (etcd): no database, no OkYouIn services. It is the third vote that lets the cluster tell “the other node is dead” from “the link is cut”.
  • One shared database. PostgreSQL on the two nodes, managed by Patroni: one node is the primary (the leader), the other a streaming replica. Every node sends its writes to the current primary, wherever it is. Users, settings, keys and the license are shared — one configuration, one master key, one license for the whole cluster.
  • Active/Active for sign-ins. Both nodes answer RADIUS, SSO and console requests. Configure your VPN gateways and network devices with both nodes as RADIUS servers.
  • Every node under its own address. Each node has its own public URL: its OIDC issuer, SAML entity IDs, Web Push origin and e-mail links. Register an OIDC or SAML application or a Windows agent against one node. To give all nodes one name, put your own load balancer in front and give every node that address as its public URL.
  • Asynchronous replication. A write does not wait for the replica. The last moments of writes on a failed primary can be lost (see Data loss on failover).

What it is not: a load balancer or floating IP (bring your own), two independent servers, or a backup — a deletion replicates at once, so keep backups.

Three hosts. Two that each meet the server requirements and are installed normally first, plus a witness host with Docker, curl, openssl and python3-cryptography. The virtual appliance works for all three: choose Shell in the first-boot wizard on the second node and on the witness.

  • The same release on all three.
  • The same time zone and NTP-synchronised clocks on every host; the join refuses otherwise.
  • Disk: about 3 GB more on each database node for replication logs, up to 5–6 GB while a member is away.
  • The node you start from (the seed) keeps its data. The node that joins later loses its own database and receives a copy of the cluster’s; a dump of what it held is kept first.

Network between the hosts — admit these ports only from the cluster’s own addresses:

PortBetweenEncrypted
2379/tcp, 2380/tcpall three (etcd)yes
5432/tcpthe database nodes (replication and writes)no
8008/tcpthe database nodes (Patroni)no (control calls need a password)
9443/tcpthe joining host → the node admitting it, only during a joinyes

One host-firewall rule per database node. The node’s own services reach its own address on 2379 and 8008 from the Docker network (10.254.90.48/28 by default). A firewall that admits only the LAN drops that. With ufw, on each database node:

Terminal window
sudo ufw allow proto tcp from 10.254.90.48/28 to <this node's address> port 2379,8008

The build tests this first and prints the rule with the address filled in when it is missing.

Latency. The cluster expects a LAN-like link between the hosts. Across a slow or jittery WAN expect needless leader changes.

Where to put the witness. On a separate failure domain — another host, ideally another room. With two sites, put the witness at a third location: if it sits at site A, losing site A takes two of three votes and site B stops accepting changes although its node is healthy.

Example addresses: seed 192.0.2.40, witness 192.0.2.41, second node 192.0.2.42. All three wizard commands run on the seed; each prints the one command to run on the other machine.

  1. Prepare the hosts. Install OkYouIn normally on .40 and .42 (own host or appliance). On .41, only unpack the bundle:

    Terminal window
    tar -xzf okyouin-bundle-<version>.tar.gz && cd okyouin

    Add the firewall rule above on .40 and .42.

  2. Declare the cluster on the seed (nothing is restarted):

    Terminal window
    ./okyouin cluster init --cluster okyouin --address 192.0.2.40 \
    --witness 192.0.2.41 --node 192.0.2.42 \
    --public-url https://mfa1.example.com --confirm TRUSTED-LINK

    Without --yes, on a terminal, it asks for anything missing and checks each answer as you give it.

  3. Add the witness on the seed:

    Terminal window
    ./okyouin cluster add-witness --address 192.0.2.41 \
    --images ../okyouin-images-<version>.tar.zst

    It prints a ./witness-join.sh … command. Run it on the witness, in the bundle directory, adding --images ../okyouin-witness-images-<version>.tar.zst. Once the witness has joined, the seed is converted (a short restart of its stack) and becomes the primary.

  4. Add the second node on the seed:

    Terminal window
    ./okyouin cluster add-node --address 192.0.2.42

    It checks every member first, then prints a ./ha-join.sh … command. Run it on .42 with that node’s own public URL, for example --public-url https://mfa2.example.com. If .42’s database holds more than a fresh install, the join lists it and asks for --confirm DISCARD-LOCAL-DATA; a dump of its database is kept in pre-join-backup/ first.

  5. Check on both database nodes:

    Terminal window
    ./okyouin cluster status

On an appliance, use SKIP_PULL=1 where these steps give --images: the images are already on the disk. Every step refuses before changing anything when a check fails and says what, why and how to fix it; running the same command again continues. ./okyouin cluster --help lists every cluster command.

Terminal window
./okyouin cluster status # the verdict first, then every machine: role, sync, lag

The first line is the verdict. Healthy means any one machine can be lost and nothing is wrong now; Degraded names the machine and the command that cures it. The console shows the same and more on Settings ▸ System ▸ Cluster, and the journals (Access log, audit log, alerts) carry a Node column.

Planned maintenance on the primary — hand the role over first, without data loss:

Terminal window
./okyouin cluster switchover --to okyouin-node-2

Writes pause for 1.5–3 s (measured); the node being demoted may drop one or two RADIUS requests, which the RADIUS client retries or sends to its other server. On the leader, a plain ./okyouin restart is a failover, so switch over first.

The witness is stopped and started on its own host with ./okyouin stop and ./okyouin start. While it is down both nodes keep working, but the cluster survives no further loss — start it again soon.

When the primary is lost, the replica is promoted automatically, as long as two of the three votes remain. Measured on a LAN:

What happened to the primaryNew primary afterChanges accepted again after
its database process was killednone needed, restarted in place≈ 8 s
its database was stopped cleanly≈ 2 s≈ 3 s
it crashed hard≈ 31 s≈ 33 s
it was cut off by the network≈ 28 s≈ 30 s

During the gap RADIUS keeps answering on every node, from each node’s own copy of the data. Console changes are refused with “no writable primary” and work again by themselves. When the old primary returns, it rejoins as a replica by itself. You see the event in cluster status, on the Cluster page, in the audit log and as the alert cluster:failover when nobody asked for it.

Two database nodes without a working witness have no automatic failover.

A node that cannot reach a writable primary — its link is cut, or the cluster has lost its majority — switches to read-only answering until the link is back. It notices within a few seconds and the console shows a red banner.

Still works on the cut-off nodeDoes not work there
RADIUS password sign-inspush, e-mail and Telegram challenges
RADIUS password + TOTP sign-inssign-in to the console, OIDC and SAML applications
OIDC discovery, JWKS and SAML metadatathe Windows agent (it applies its offline rule) and the Verify API
console pages for an administrator already signed in, read-onlyany change: users, settings, enrolment, password changes
backups and restores

The node answers from its own copy of the data as of the last replicated moment: a user disabled on the other side is still accepted here until the link is back. What it would have written — RADIUS log rows, accounting, alerts — is queued on its disk and delivered exactly once, with the original times, when the link returns. The console’s sign-in page still checks the password and tells a user with the right password where the primary is.

Replication is asynchronous, so a failover can lose data in two ways:

  • At a crash, a replica is promoted only if it is at most 1 MiB behind; the loss is bounded by that. The alert cluster:replica_lag warns when a replica falls more than 60 s or 1 MiB behind.
  • When the primary itself is cut off, it keeps accepting writes until it notices — about 12–20 s measured — while the other side promotes its replica. When the link is back, the writes it accepted in that window are discarded. This is journalled: the alert Data written on … was discarded names the node and the time window, and the audit log lists what was affected. Redo what is missing and resolve the alert.

Two writable primaries never exist at the same time.

Cluster problems raise alerts in the console (and to e-mail and syslog as configured), such as cluster:node_down, cluster:etcd_member_down, cluster:failover, cluster:replica_lag and cluster:data_discarded. Because a cut-off node cannot record alerts, every database node also checks the cluster itself every 30 s and e-mails its own view to the alert recipients and every active administrator with an e-mail address — after 2 minutes of trouble, with a reminder every 30 minutes and a “restored” message at the end. Only SMTP must be configured.

The same ./okyouin update as on a single server, one machine at a time: every replica, then the leader, then the witness. Each database node is out for about a minute (measured: RADIUS ≈ 60 s, console ≈ 55 s) while the other keeps serving. Start on any member — the update names where to begin. Details in Updating.

All run on a database node that stays:

GoalCommand
Take a database node out (never the leader: switch over first)./okyouin cluster remove-node --node <name>
…then, at once, on the removed machine./okyouin uninstall --confirm=DELETE-ALL-DATA
A machine that is gone for good./ha-deconvert.sh --decommission-dead --node-name <name> --node-address <address>
Rebuild a node at the same address./okyouin cluster add-node --address <address> --reinstall
Rebuild the witness./okyouin cluster add-witness --address <address> --reinstall
Back to a single serverremove-node every other node, then ./ha-deconvert.sh on the last one

A removed machine keeps serving until it is wiped, and it still holds the data and the cluster’s keys. Afterwards replace the cluster’s certificate authority: ./okyouin cluster rotate-ca.

  • The cluster’s internal certificates are renewed automatically 45 days before they expire, with nothing restarted. ./okyouin cluster renew-cert --all does it now.
  • The console’s HTTPS certificate is shared: every node serves the same one, so it must name every node’s address (or your load balancer’s name) — see TLS certificate management.
  • When the cluster misbehaves, run ./okyouin diagnose --ha on every machine — both nodes and the witness — and send all the archives together (Diagnostics for support).
  • Push, e-mail, Telegram, OIDC, SAML and Windows agent sign-ins on a cut-off node.
  • Per-node HTTPS certificates.
  • A built-in load balancer or floating IP.
  • Online updates: an update always comes from a bundle copied to each machine.