After this chapter you can:
- Set up a three-node cluster and confirm that data written to one node can be read from the others
- Understand leader, followers, replication and snapshots, and know what the server does when it loses the leader
- Handle a node failure: restart a node, or rebuild its data from the other nodes
- Add a new node to the cluster and remove a node safely
- Deploy a three-node cluster with Docker Compose or Kubernetes
Prerequisites: you have worked through chapter 03 and know how to start the server and test logins with rradius-bench; you have read chapter 04 and know check and reload. The exercises in this chapter run three to four nodes on one machine. You need rradiusd and rradius-bench built from the source, and rradius-server/examples/scenarios/ha-cluster/ from the source.
In this chapter:
- Concepts
- cluster settings
- Three nodes on one machine
- Check that the cluster has formed
- Check that writes are replicated
- Stop the leader
- Lose the majority
- Restarting nodes and rebuilding data
- Add a node
- Remove a node
- Check the settings of each node
- See the state of the whole cluster
- Several hosts: the ha-cluster scenario
- Deploy with Docker Compose
- Deploy on Kubernetes
- Across data centers
- Cluster metrics
- Common mistakes
- Related chapters
Concepts
A single node is also a cluster
rradius keeps its accounts, reply attributes and accounting data in an SQLite database embedded in each node (hiqlite). The nodes replicate this database with the Raft protocol, and every node holds a complete copy.
So the configuration always needs [cluster], even on a single machine. When you run only one machine, it is a cluster with one node:
- Without
[[cluster.nodes]], the cluster has only node 1, the Raft port is127.0.0.1:8100and the API port is127.0.0.1:8200. Both ports listen on127.0.0.1only by default. - To grow to three nodes later, the tables and scripts stay as they are. You only change
[cluster].
Leader, followers and writes
At any moment the cluster has at most one leader. The other nodes are followers.
- Read: the script’s
sql_queryand thesqlhandler’s password lookup read the local copy. They do not use the network. - Write: the script’s
sql_executeand commands such asuser addgo to the leader. A write succeeds after the leader has the confirmation of a majority of the nodes. A write that a follower receives is forwarded to the leader.
Because a write needs a majority, the cluster can write only while a majority of the nodes is alive:
| Nodes | Majority | How many can be down at the same time |
|---|---|---|
| 1 | 1 | 0 |
| 2 | 2 | 0 |
| 3 | 2 | 1 |
| 4 | 3 | 1 |
| 5 | 3 | 2 |
A cluster of two nodes is more fragile than one node: when either stops, writes stop. So when only one or two voters would remain, cluster remove removes a node only with --force (see Remove a node).
When the leader stops, the remaining nodes elect a new leader by themselves. Nobody has to step in.
Stopping one node and stopping two
What happens to authentication and accounting when you stop nodes of a three-node cluster (for the details of each kind of request when there is no leader, see “When there is no leader” below):
| Situation | Authentication | Accounting |
|---|---|---|
| All three up | Normal | Normal |
| One stopped | Normal; the NAS asks another node. When the stopped node is the leader, logins that need a write get no answer during the election (for the time, see Across data centers) | Normal. When the stopped node is the leader, writes time out during the election; with an accounting spool they go to the spool first and are replayed later, possibly once more than needed |
| Two stopped, one left | Logins that only read data (sql, ldap) read the local copy and are answered as usual; logins that write (verification codes, IP allocation) get no answer, so the NAS retransmits or asks another node. When stop_without_leader_ms is set, even read-only logins get no answer after that time | Cannot write to the database; with an accounting spool the request is written locally and answered, and replayed when the cluster recovers |
Accounting can be replayed, and can also be recorded twice because of a retransmit after a timeout, so the accounting script has to be safe to run more than once (for example keyed on Acct-Session-Id with INSERT OR IGNORE); see chapter 13.
When the database cannot be used, the server does not answer instead of rejecting. When a login cannot be decided because the cluster database timed out or found no leader, RADIUS sends no reply and TACACS+ answers ERROR. The NAS or device then asks another node, and the user does not see “wrong password”. Such requests are counted in rradius_radius_discarded_total{reason="database"}, and the log says not answered: the cluster database could not be used. The server rejects only when it is sure the account does not exist or the password is wrong, and all database calls of the script succeeded.
A node cut off from the others reads old data. While it is separated from the majority, an account disabled on the other side, a NAS deleted there, or a key revoked there is still valid on this node until the network recovers. If you cannot accept that, set stop_without_leader_ms.
A node serves only after it has caught up
When a node starts, it does not answer requests at once. It does these things in order:
- Start the local cluster node. A node that starts for the first time has to join the cluster first.
- Wait for a leader that can accept writes, for at most
migrations_wait_ms(60000 ms by default). - If there is a
migrations_dir, apply the migrations that are not yet applied (chapter 18). - Write a marker of its own through the leader, and wait until the local copy reads this marker back. Only then has it caught up. The log says
cluster node N has caught up with the cluster. - Open the RADIUS, TACACS+ and metrics ports. The log says
Servers started.
Step 4 guarantees that a node that was down for two hours answers its first request with the accounts added during those two hours already visible. The metrics port also opens only after this, so during startup even /livez cannot be reached.
Snapshots
Raft records every write in a log. The log keeps growing, so after every snapshot_every applied entries (100000 by default) the node saves a snapshot of the database, and older log entries can then be discarded. A node that is new or has fallen too far behind takes a snapshot from the leader and then catches up with the log from there.
A snapshot is for replication, not a backup. The core edition has no backup feature; for how to protect the data, see chapter 18.
When there is no leader
A node that has lost contact with the other nodes and cannot reach a majority has no leader that it can write to. What it does then depends on stop_without_leader_ms:
| Situation | stop_without_leader_ms not set (default) | Set, and there has been no leader for longer than this time |
|---|---|---|
Logins that only read data (for example the sql handler looking up a password) | Answered as usual from the local copy; the data may be old | No answer; counted in rradius_radius_discarded_total{reason="no_leader"} |
| Status-Server | Answered as usual | No answer |
| Logins whose script writes | No answer (the write fails) | No answer |
| Accounting | For the first few seconds the write waits for a leader and there is no answer; once there has been no leader for more than 5 seconds the write fails at once, and with an accounting spool the request is written to the spool and answered, without one there is no answer | Same as on the left |
| TACACS+ authentication and authorization | Answered as usual from the local copy | ERROR |
| TACACS+ accounting | Handed to the script as usual | Not affected by stop_without_leader_ms |
/readyz | 200 | 503 no leader |
Two more rules about time:
- Once there has been no leader for more than 5 seconds, new writes fail at once and do not wait any more. An accounting request whose write failed goes to the accounting spool when there is one (chapter 13).
- The exception is the first write after the majority is lost: it was handed to the cluster before the 5 seconds had passed, so it waits until the cluster’s 30 second timeout before it fails, and
query_timeout_msdoes not limit it. The message isthe cluster took the write and said nothing of it within 30 s; it may have been committed(the write may have taken effect by then, so do not assume it was not written). When only the leader itself is left in the cluster, the message islocal client write timed outand the login gets no answer. Measured: with two of three nodes stopped, the first write on the remaining node failed after 30 seconds, later writes failed within 12 milliseconds, and reads kept succeeding at once. This was measured with authentication writes; accounting writes and overlapping writes were not measured. - A leader that has not had the confirmation of a majority for more than 5 seconds also counts as having no leader. An old leader that has been cut off does not think it can still write.
When should you set stop_without_leader_ms? When the NAS has several RADIUS servers configured. With it set, a node that is cut off stops answering, so the NAS asks the other nodes that are still in the cluster, and /readyz lets a load balancer take the node out. The Kubernetes example sets 10000. For a NAS that has only one server to ask, it is better not to set it: at least the read-only logins can still pass.
Cluster ports and security
Every node opens two ports for the cluster:
raft: used between nodes for replication.api: used between nodes to forward writes and for membership management; commands such asuser,sessionandclusteralso talk to the cluster through it.
These two ports are protected only by shared secrets (secret_raft, secret_api), and the traffic itself is not encrypted. So:
- Set
listento the node’s internal address or WireGuard address, and do not let the outside network reach it. - When the nodes are in different data centers or connected over a public network, the traffic between nodes has to go through an encrypted tunnel, for example WireGuard. The ha-cluster scenario is designed this way: the node addresses are in the WireGuard network
10.99.0.0/24, andlistenlistens on the WireGuard interface only. How to set up WireGuard itself is outside the scope of this book.
Note: When there is
[[cluster.nodes]]and nolisten, the two ports listen on0.0.0.0, and bothcheckand startup warncluster.listen is not set, so the cluster's Raft and API ports are on all interfaces, …. If you really want to listen on all addresses (for example in a container), writelisten = "0.0.0.0"and the warning goes away.
cluster settings
Every key of [cluster] needs a restart to take effect; on reload the log lists [cluster] after these need a restart to apply:. For the full types and defaults, see Appendix A.
| Key | Default | Meaning |
|---|---|---|
node_id | 1 | The id of this node, at least 1; it has to appear in nodes |
data_dir | required | Directory for the database and the Raft log, relative to the configuration file |
listen | 127.0.0.1 without nodes, 0.0.0.0 with nodes | The address the raft and api ports listen on; the port numbers come from this node’s entry in nodes |
nodes | only node 1, 127.0.0.1:8100, 127.0.0.1:8200 | The list of nodes of the cluster; each entry has id, raft and api, all written as host:port |
secret_raft, secret_raft_file | one of the two, required | Shared secret of the Raft port, at least 16 characters, the same on every node |
secret_api, secret_api_file | one of the two, required | Shared secret of the API port, at least 16 characters, the same on every node |
migrations_dir | none | Directory of SQL files applied at startup (chapter 18) |
migrations_wait_ms | 60000 | Time limit for each of the three startup steps (wait for a leader, apply migrations, catch up), in milliseconds |
snapshot_every | 100000 | Number of Raft log entries between two snapshots |
read_connections | twice the number of worker threads, at most 32 | Number of connections that read the local database, 1 to 128 (chapter 19) |
stop_without_leader_ms | none (always answer) | After there has been no leader for longer than this time, do not answer logins and Status-Server, in milliseconds |
Rules for nodes (check fails when they are broken):
- There has to be a node with id 1:
cluster.nodes: node 1 is required. Node 1 is the one that creates the cluster on the first start. - Ids cannot repeat, and cannot be 0.
node_idhas to be in the list:cluster.node_id 4 is not in cluster.nodes.- Addresses have to be
host:port:cluster.nodes: node 1 raft '10.0.0.1' must be host:port.hostcan be a name, for examplerradius-0.rradius-clusterin Kubernetes.
In the configuration of every node, nodes lists all the nodes, including itself. Apart from the local values such as node_id and listen, the configurations of the nodes should preferably be identical. For how to check this with config diff, see Check the settings of each node.
When nodes is set and has more than one node, the default of ready_delay_ms in [shutdown] becomes 5000 (0 for a single node), to give the NAS and load balancers time to ask other nodes. [shutdown] is described in chapter 04, and the order of shutdown in chapter 18.
What belongs to each node
The tables are replicated automatically, but the things below are not. Check them one by one when you plan several nodes:
| Item | Per node | Note |
|---|---|---|
Configuration file, scripts, dictionary, migrations_dir | One copy each | The content has to be the same. After a change, update every machine and reload or restart each one (check with config diff) |
secret_raft_file, secret_api_file, the NAS shared secret files | One copy each | The content has to be the same |
| Certificates, private keys, revocation lists | One copy each | Replace them on every machine when you renew them, and send SIGHUP to each |
| Accounting spool | Each node replays only its own files | Keep it on a persistent disk. When a node breaks, what it has not replayed yet is lost. rradius_acct_spool_bytes above 0 means accounting that is not yet in the database; you can alert on it |
| EAP conversations in progress | Only on the node that received them | One login has to stay on one node (chapter 11) |
| Cluster state | Each node sees its own | See Cluster metrics |
Metrics and the timing of [log.trace] | Each node’s own | Add up the cluster total in the monitoring system; for a user you want to trace, set it on every machine |
Tuning
read_connections: logins are mostly reads, and when there are not enough connections, requests queue. When memory is tight you can lower it; every connection has its own cache.snapshot_every: when you lower it, a restart after an abnormal exit (power loss, SIGKILL) is faster, but with many writes, snapshots that are too frequent slow the service down.- More nodes do not raise the write limit. Every write goes through the same leader and waits for the confirmation of a majority, and between separate hosts it also waits for the round trips between the nodes (see Across data centers). Logins (reads) are handled by each node on its own, so the more nodes, the higher the total.
The defaults and ranges of the three are in the table above. All need a restart, and for how to measure see chapter 19.
Three nodes on one machine
Goal: run three nodes on one machine, and use them for the practice in the following sections.
Note: This is a way to practice, and it differs from a multi-host deployment in a few ways:
- All three nodes are on
127.0.0.1, so every node needs different ports and a differentdata_dir. In production every host uses the same ports (for example 8100, 8200, 1812, 1813, 9812), and only the addresses differ.- Stopping a node means stopping a process. You do not meet network partitions, packet loss or clock skew, which only happen with several hosts. The seconds measured in this chapter apply to this machine only.
status --clustercannot see the other nodes this way; see See the state of the whole cluster.
Prepare the directory
Run these commands from the root of the source repository:
$ export PATH="$PWD/target/release:$PATH"
$ mkdir -p ~/rradius-lab/cluster
$ cp -R rradius-server/examples/scenarios/ha-cluster/accounting.lua \
rradius-server/examples/scenarios/ha-cluster/migrations ~/rradius-lab/cluster/
$ cd ~/rradius-lab/cluster
$ for f in raft api nas; do openssl rand -hex 32 > $f.secret; done
$ chmod 600 *.secret
accounting.luaandmigrations/are the same as in the quick-start scenario: the three tablesusers,user_replyandaccounting, and the demo accounts.raft.secretandapi.secretare the cluster secrets, andnas.secretis the NAS shared secret. The three nodes share these three files; on several hosts, you copy the same files to every host.
Settings for node 1
The exercises in this chapter use ports in the 27000 range, to avoid clashing with the default ports of other programs on the system:
| Node | node_id | data_dir | raft | api | RADIUS auth/acct | TACACS+ | Metrics |
|---|---|---|---|---|---|---|---|
| 1 | 1 | data1 | 27001 | 27011 | 27021/27031 | 27051 | 27041 |
| 2 | 2 | data2 | 27002 | 27012 | 27022/27032 | 27052 | 27042 |
| 3 | 3 | data3 | 27003 | 27013 | 27023/27033 | 27053 | 27043 |
| 4 (used in Add a node) | 4 | data4 | 27004 | 27014 | 27024/27034 | 27054 | 27044 |
# node1.toml
dictionary = "/path/to/share/dictionary" # change to the absolute path of the dictionary
[lua]
script = "accounting.lua"
query_timeout_ms = 2000
[cluster]
node_id = 1
listen = "127.0.0.1"
data_dir = "data1"
secret_raft_file = "raft.secret"
secret_api_file = "api.secret"
migrations_dir = "migrations"
migrations_wait_ms = 120000
[[cluster.nodes]]
id = 1
raft = "127.0.0.1:27001"
api = "127.0.0.1:27011"
[[cluster.nodes]]
id = 2
raft = "127.0.0.1:27002"
api = "127.0.0.1:27012"
[[cluster.nodes]]
id = 3
raft = "127.0.0.1:27003"
api = "127.0.0.1:27013"
[auth]
policy = "first_match"
[[auth.handlers]]
type = "sql"
user_query = "SELECT password FROM users WHERE username = ? AND enabled = 1"
reply_query = "SELECT attribute, value FROM user_reply WHERE username = ?"
[accounts]
add = "INSERT INTO users (username, password) VALUES (?1, ?2)"
show = "SELECT username, enabled FROM users WHERE username = ?1"
[sessions]
list = "SELECT username, nas, session_id, started, updated FROM accounting WHERE stopped IS NULL ORDER BY started, session_id"
[radius]
bind = "127.0.0.1"
auth_port = 27021
acct_port = 27031
status_server = true
[[radius.clients]]
name = "localhost"
address = "127.0.0.1"
secret_file = "nas.secret"
[radius.accounting_spool]
dir = "spool1"
[tacacs]
bind = "127.0.0.1"
port = 27051
[[tacacs.clients]]
name = "localhost"
address = "127.0.0.1"
secret_file = "nas.secret"
[metrics]
bind = "127.0.0.1"
port = 27041
A few choices that matter for the cluster:
query_timeout_ms = 2000: the total time one request waits for the database. After the cluster loses the majority, the first write that was already handed to the cluster still waits 30 seconds before it fails (see the rule above), and this value does not shorten that; it limits the script’s reads and the writes that have not been handed over yet. The ha-cluster scenario uses the same value.migrations_wait_ms = 120000: when all three nodes restart together, the node that comes up first has to wait for the others, so give it a longer time.[radius.accounting_spool]: when the database cannot be written, accounting is written to the local disk first and sent again later (chapter 13). Every node uses its own directory.[accounts],[sessions]: let this chapter confirm replication withuser addandsession list(chapter 07, chapter 13).
Copy node1.toml to node2.toml and node3.toml, and change node_id, data_dir, the RADIUS, TACACS+ and metrics ports as in the table above, and the dir of [radius.accounting_spool] (spool2, spool3). The [[cluster.nodes]] entries of the three files are exactly the same.
$ for n in 1 2 3; do rradiusd check --config node$n.toml; done
configuration ok
configuration ok
configuration ok
Start them together
Start the three nodes together: the node that comes up first waits until a majority has gathered before it starts serving. Open a terminal for each node, or put them in the background like this and write the logs to files:
$ for n in 1 2 3; do rradiusd serve --config node$n.toml > node$n.log 2>&1 & done
On this machine, it takes about 9 seconds from start until /readyz of all three nodes answers ok. The log of node 1 (timestamps removed):
WARN hiqlite::store::state_machine::sqlite::writer: No metadata exists inside the DB yet
WARN hiqlite::store::state_machine::sqlite::writer: No metadata exists inside the DB yet
ERROR hiqlite::init: Config: Raft node has not been initialized
…
INFO rradius_core::cli: cluster node 1 started
INFO rradius_core::cli: cluster node 1 has caught up with the cluster
INFO rradius_core::cli: Servers started. Press Ctrl+C to stop.
INFO rradius_core::radius: RADIUS Server listening on 127.0.0.1:27021 and 127.0.0.1:27031
INFO rradius_core::tacacs: TACACS+ Server listening on 127.0.0.1:27051
INFO rradius_core::metrics: Metrics listening on 127.0.0.1:27041
Until the cluster has formed, the logs of nodes 2 and 3 have several lines of ERROR hiqlite::init: … Raft is not initialized or Connection refused: they are waiting for node 1 to create the cluster. As long as has caught up with the cluster follows, you can ignore these ERROR lines.
Check that the cluster has formed
cluster members
cluster members asks the nodes in the configuration who the leader is, and then lists the members as the leader sees them:
$ rradiusd cluster members --config node1.toml
node 1 voter leader raft 127.0.0.1:27001 api 127.0.0.1:27011
node 2 voter raft 127.0.0.1:27002 api 127.0.0.1:27012
node 3 voter raft 127.0.0.1:27003 api 127.0.0.1:27013
voter: a node that votes and counts toward the majority. A node that has just joined and is still catching up is alearnerfor a while.leader: the current leader. Which node is the leader is not fixed.- You can use the configuration file of any node; the command finds the leader by itself.
- Exit codes: 0 success; 2 a bad argument or configuration, or a wrong API secret; 3 no node reported a leader within 30 seconds.
The Node section of status
status reads the metrics port of one node. The Node section is the cluster as this node sees it:
$ rradiusd status --config node2.toml
rradius status of 127.0.0.1:27042 over 1.0 s
Node
Ready ok
Leader 0
Has a leader 1
Caught up 1
Applied index 16
Seconds without a leader 0
Version 0.1.0
Seconds running 13
…
| Line | Meaning |
|---|---|
Ready | The content of /readyz: ok, no leader, stopping |
Leader | Whether this node is the leader (1 is yes) |
Has a leader | Whether this node has a leader that it can write to |
Caught up | Whether the node has caught up with the cluster since startup |
Applied index | Up to which Raft log entry the local copy has applied; the numbers of the nodes should be close |
Seconds without a leader | How long there has been no leader; 0 when there is a leader |
The other sections of status are described in chapter 17.
Check that writes are replicated
Goal: write to one node and read from another.
Add an account through the configuration of node 1, then log in once on each of the three nodes:
$ printf 'erin-password\n' | rradiusd user add --config node1.toml erin
added erin
$ rradiusd user show --config node3.toml erin
username=erin
enabled=1
$ for n in 1 2 3; do rradius-bench run --server 127.0.0.1 --auth-port 2702$n --secret "$(cat nas.secret)" \
--user erin --password erin-password --load pap,concurrency=1 --requests 1 | grep 'pap:'; done
pap: 26/s, sent 1, accept 1, reject 0, challenge 0, accounting 0, timeouts 0, invalid 0, late 0, socket errors 0, retransmits 0
pap: 26/s, sent 1, accept 1, reject 0, challenge 0, accounting 0, timeouts 0, invalid 0, late 0, socket errors 0, retransmits 0
pap: 26/s, sent 1, accept 1, reject 0, challenge 0, accounting 0, timeouts 0, invalid 0, late 0, socket errors 0, retransmits 0
Now send one accounting request to node 2 and look at it from node 3:
$ rradius-bench run --server 127.0.0.1 --acct-port 27032 --secret "$(cat nas.secret)" \
--user erin --load acct-start,concurrency=1 --requests 1 | grep 'acct-start:'
acct-start: 729/s, sent 1, accept 0, reject 0, challenge 0, accounting 1, timeouts 0, invalid 0, late 0, socket errors 0, retransmits 0
$ rradiusd session list --config node3.toml
username=erin
nas=192.0.2.1
session_id=4220000000000000
started=1795384786
updated=1795384786
The script write on node 2 goes to the leader. The leader replies only after a majority has confirmed, and only then does node 2 send the Accounting-Response. When accounting 1 appears, the data is already in the cluster.
Stop the leader
Goal: stop the leader, and watch the cluster elect a new leader by itself and writes resume.
First find the leader with cluster members (node 1 above) and send it SIGTERM. At the same time send an accounting request to node 2 every 0.5 seconds and see whether writes are interrupted. The course measured on this machine:
| Time since SIGTERM | Old leader (node 1) | Accounting to node 2 |
|---|---|---|
| 0 s | /readyz changes to 503 stopping, but requests are still answered | As usual |
| 5 s | Stops accepting new requests (ready_delay_ms defaults to 5000) and waits for requests in progress | As usual |
| about 14.5 s | Closes the database, the process exits | Starts to slow down, one request times out |
| about 19 s | — | Node 3 is elected the new leader |
| about 25 s | — | Back to normal |
- During the 14.5 seconds of shutdown the old leader is still the leader, so writes continue as usual. The time with no leader is from when it closes the database until the new leader can accept writes, about 10 seconds on this machine.
- During this time, logins that only read data are not affected: followers answer from the local copy.
rradius_cluster_leaderon node 2 stays at 1: the metric is updated once per second, and during the election a follower still knows some leader. So do not judge from this metric alone whether writes are interrupted; look at the responses to accounting and at the accounting spool as well.
After the new leader is elected:
$ rradiusd cluster members --config node2.toml
node 1 voter raft 127.0.0.1:27001 api 127.0.0.1:27011
node 2 voter raft 127.0.0.1:27002 api 127.0.0.1:27012
node 3 voter leader raft 127.0.0.1:27003 api 127.0.0.1:27013
Node 1 has stopped, but it is still a voter: stopping is not the same as leaving the cluster. With one of three voters stopped, the remaining two are still a majority, so writes still work.
Start node 1 again. It comes back as a follower and starts serving only after it has caught up:
INFO rradius_core::cli: cluster node 1 started
INFO rradius_core::cli: cluster node 1 has caught up with the cluster
INFO rradius_core::cli: Servers started. Press Ctrl+C to stop.
Note: Do not stop a node with
kill -9. A node that was killed has to rebuild its local database at the next start (see Restarting nodes and rebuilding data). In a multi-node cluster, the process exited about 15 seconds after SIGTERM on this machine, so the wait time of systemd, Docker and Kubernetes has to be longer than that; see chapter 18.
Lose the majority
Goal: see what a node does when it cannot reach a majority, and what stop_without_leader_ms does.
Add this to [cluster] of node 1:
# node1.toml (add to [cluster])
stop_without_leader_ms = 10000
Restart node 1 so that it takes effect, then send SIGTERM to nodes 2 and 3 and wait until both processes have exited. After that, every ten or so seconds, send node 1 a PAP login, a Status-Server, an accounting request and a TACACS+ login. Measured results:
| After the two nodes stopped | Seconds without a leader | /readyz | PAP login | Status-Server | Accounting | TACACS+ login |
|---|---|---|---|---|---|---|
| 0 s | 0 | 200 ok | accept | answered | no answer | accept |
| 8 s | 2 | 200 ok | accept | answered | no answer | accept |
| 16 s | 10 | 503 no leader | no answer | no answer | answered (written to the spool) | ERROR |
| 69 s | 63 | 503 no leader | no answer | no answer | answered (written to the spool) | ERROR |
- Node 1 noticed after about 6 seconds that there was no leader.
- Accounting in the first few seconds got no answer: the script’s write was waiting for a leader. The first write after the majority is lost waits for the cluster’s 30 second timeout (not
query_timeout_ms), and the NAS retransmits. - Once there has been no leader for more than 5 seconds, writes fail at once, and accounting is written to the spool and answered to the NAS.
- Once there has been no leader for more than 10 seconds (
stop_without_leader_ms), logins and Status-Server get no answer and are counted inrradius_radius_discarded_total{reason="no_leader"}; TACACS+ authentication answers ERROR (rradius-benchprintsstatus: 0x07)./livezstays 200: the process is alive, only not ready.
What status looks like:
$ rradiusd status --config node1.toml
rradius status of 127.0.0.1:27041 over 1.0 s
Node
Ready no leader
Leader 0
Has a leader 0
Caught up 1
Applied index 96
Seconds without a leader 84
…
Accounting spool
Bytes waiting 545
Replayed 0.0/s (0)
…
The log keeps showing Find DB leader error: Connect: Leader vote is in progress, and a failed script write is logged as Lua script error (radius/accounting): runtime error: no leader for 83 s.
Now start nodes 2 and 3. A few seconds after the cluster has a majority again, /readyz of node 1 returns to ok, and the 5 accounting requests in the spool are sent into the database automatically:
rradius_cluster_leader 1
rradius_cluster_seconds_without_leader 0
rradius_acct_spool_written_total 5
rradius_acct_spool_replayed_total 5
rradius_acct_spool_bytes 0
Restarting nodes and rebuilding data
Normal restart
Stop a node (SIGTERM) and start it again. It comes back with the data in its own data_dir, takes the writes made during its downtime from the leader, and serves only after it has caught up. This is the standard way for upgrades, for changing the [cluster] settings and for replacing host hardware.
Note: When you start a node in the few seconds right after the cluster got its majority back and is still electing, the node’s read of “which migrations the cluster has applied” gets
has to forward request to: None. Now it reads again every 200 ms until the leader answers, withmigrations_wait_msas the upper limit; after that it exits with exit code 1, and the last line isnot ready to apply migrations: cannot read applied migrations: …, carrying the last error. Older versions did not read again, and in this situation exited after a few seconds, so you had to rely onRestart=on-failureof systemd or the restart policy of the container to start it once more. This retry is covered by a unit test; the gap during an election itself has not been reproduced on real machines.
After a forced stop
Kill node 3 with kill -9 and start it again. The log:
WARN hiqlite_wal::log_store: LockFile data3/logs exists already - this is not a clean start!
WARN hiqlite::store::state_machine::sqlite::state_machine: Lock file already exists: data3/state_machine/lock\nNode did not shut down gracefully - auto-rebuilding State Machine
…
INFO rradius_core::cli: cluster node 3 started
INFO rradius_core::cli: cluster node 3 has caught up with the cluster
When a node was not shut down cleanly, the next start rebuilds the local database from the Raft log. With little data this is fast; with a lot of data it takes longer.
The server also exits on its own in some situations, with exit code 1, so that the process manager restarts it:
- The Raft core of the node stopped because of an error, for example a follower fell so far behind that the leader had already discarded the log entries it needs. The log says
cluster node N: its Raft core stopped (…); exiting so that a restart recovers it. - A panic occurred in the cluster library:
cluster node: a panic in its database (…); exiting so that a restart recovers it.
Rebuild from the other nodes
When the disk of a node has failed, its data directory is gone, or you suspect its data is wrong: stop it, empty its data_dir, and start it again with the same configuration (the same node_id and addresses). It copies the data back from the other nodes.
$ rm -rf data3
$ rradiusd serve --config node3.toml > node3.log 2>&1 &
WARN hiqlite::init: Found remote metrics and we (3) are a Raft member
…
INFO rradius_core::cli: cluster node 3 started
INFO rradius_core::cli: cluster node 3 has caught up with the cluster
On this machine it takes about 2 seconds from start to ready, after which erin logs in on node 3 with accept. This way needs a majority of the other nodes to be still running.
Warning: Do not empty the
data_dirof a majority of the nodes at the same time. The data exists only on the nodes of the cluster, and when the copies on a majority are gone, the data is gone.
Replace a failed host
When a host is broken and its data cannot be recovered, replace it with a new host. You do the same as above, but the configuration has to match:
- The new host uses the same
node_idand the same addresses (itsraftandapiin[[cluster.nodes]]); the configuration file, secret files andmigrations_dirare the same as on the other nodes. If you have added or removed nodes before,[[cluster.nodes]]has to list all the current members (look withcluster membersfirst). data_diris empty. When the old host’s data still exists but cannot be trusted, delete it completely before you start.- Start. It gets the whole data from the other nodes, and it starts answering only after the log shows
cluster node N has caught up with the cluster. - Confirm:
rradius_cluster_applied_indexis close to the other nodes andrradius_cluster_leaderis 1; log in once on it with an account that was added while it was down.
- A majority of the other nodes has to be online. The new node gets its data from them.
- It is the same when the broken node is the leader. The remaining nodes elect a new leader by themselves; logins that need a write get no answer during the election, and accounting goes to the spool and is sent later (for the seconds see Across data centers).
- It does not matter if the leader has made a snapshot and discarded old log entries, because the new node receives the snapshot directly.
- Management commands wait a little longer. In the time right after the leader stopped, commands such as
userconnect to the old leader first and switch to the new one only after the connection times out, so they may take more than ten seconds, with 30 seconds as the limit. - The same id is not stopped by
node id N is in use: when the old address does not answer, the check passes as usual (see When the id is already in use). - What was tested: on 2026-11-13, with the three nodes of
compose.cluster.yaml, in Docker on one host, a broken host was simulated by force-stopping and deleting the container and its data volume. A replaced follower caught up in about 2 seconds; after settingsnapshot_every = 50and writing about 200 entries so that the leader had made a snapshot, a replaced leader caught up in about 5 seconds, the applied index was the same on all three, and the account added in the meantime could log in on every node. It was not tested on several physical hosts or through WireGuard.
Restart the whole cluster
Stopping all three nodes together and starting them together is the same as the first start: every node waits until a majority has gathered and it has caught up before it serves, for at most migrations_wait_ms. So migrations_wait_ms has to be longer than the time you expect “the last node comes up” to take.
When only one node is restarted and the other two have not come back (without stop_without_leader_ms, and with all migrations already applied locally), the program is designed like this: if it cannot get a leader, it compares the migrations already applied in the local copy, and when they match it prints a warning and serves from the local copy. It was tested three times, and the results were not consistent:
- Once as designed: after about 4 seconds it printed
cluster node 1: no usable leader within 3.981301833s; serving without a leader before catching up, so answers come from this node's replica, which may be behind, then served from the local copy, andrradius_cluster_caught_upwas 0. After the other two nodes came back, the log saidcluster node 1 has caught up with the clusterandrradius_cluster_caught_upbecame 1. - Twice (
migrations_wait_ms = 10000) it did not serve and exited with exit code 1: once it printednode 2 did not join within 10s, the other timecannot read applied migrations: no answer within 8.990975917s.
A node with stop_without_leader_ms set always exits when it cannot get a leader, with exit code 1, and does not serve from old data.
Conclusion: when you have lost the majority, do not count on restarting one node to make it serve; bring the other nodes back first.
Add a node
Goal: let a fourth node join the running cluster, without restarting any other node.
A new node joins by itself; there is no “join” command. The conditions:
- The new node’s
data_diris empty (or does not exist). - The
[[cluster.nodes]]of its configuration lists itself and the current leader. The simplest way is to list all the nodes. node_idis not used by any other running node.
Make node4.toml following the table in Settings for node 1, with [[cluster.nodes]] listing nodes 1 to 4, and then start it:
$ rradiusd serve --config node4.toml > node4.log 2>&1 &
On this machine it is ready after about 4 seconds, and the log shows cluster node 4 started, has caught up with the cluster and Servers started in turn. An account created before it joined can log in on node 4 at once:
$ rradius-bench run --server 127.0.0.1 --auth-port 27024 --secret "$(cat nas.secret)" \
--user erin --password erin-password --load pap,concurrency=1 --requests 1 | grep 'pap:'
pap: 22/s, sent 1, accept 1, reject 0, challenge 0, accounting 0, timeouts 0, invalid 0, late 0, socket errors 0, retransmits 0
$ rradiusd cluster members --config node1.toml
node 1 voter raft 127.0.0.1:27001 api 127.0.0.1:27011
node 2 voter raft 127.0.0.1:27002 api 127.0.0.1:27012
node 3 voter leader raft 127.0.0.1:27003 api 127.0.0.1:27013
node 4 voter raft 127.0.0.1:27004 api 127.0.0.1:27014 (not in this configuration)
(not in this configuration) means that the list in node1.toml does not have node 4. This does not affect operation: nodes 1 to 3 do not have to be restarted because of node 4, and they come back as usual when they are restarted. Looking with node4.toml shows no such mark. Find time later to add node 4 to the configuration of the other nodes, so that the lists of all nodes agree and cluster members stops reminding you.
Note: Keep the total number of nodes odd. Going from 3 to 4 nodes changes the majority from 2 to 3, and the number of nodes that can be down at the same time is still only 1.
A few details when a new node joins:
- A node that joins with empty data has to list the current leader. It asks to join only the nodes listed in its own configuration, and the other nodes only tell it to go to the leader; if the leader is not in its list, it cannot join. When the configuration has
migrations_dir, it waits untilmigrations_wait_msand exits with exit code 1 with the messagenode N did not join within …, and after the process manager restarts it, it starts over. So listing all current members is the safest. Measured on 2026-11-13: after the leader had changed to node 4, a node 1 with empty data whose configuration listed only 1 to 3 could not join; after node 4 was added, it joined within 8 seconds. - A node that restarts with its data is not affected. It knows the members from its own data, and can return to the cluster even when the configuration does not list the leader (about 14 seconds in the same test).
- A node with a different secret cannot join, and the log of the new node gives the reason: a different
secret_raftgivesInvalid ChallengeResponse, a differentsecret_apigivesInvalid API Secret; the members of the cluster do not change (measured on 2026-11-18). - When the new node’s
migrations_dirhas one file more than the others, on 2026-11-18 only joining and restarts of the other nodes were looked at; both worked as usual, and the logs did not mention the difference. Themigrations_dirof every node has to stay the same; this combination was not examined in depth.
When the id is already in use
When the node_id of the new node is the id of a node that is still running, but with a different address, it refuses to start, with exit code 2:
cannot start cluster node 2: node id 2 is in use: the cluster has it at api 127.0.0.1:27012 (raft 127.0.0.1:27002), and that node answers, but this node's configuration gives it api 127.0.0.1:27015 (raft 127.0.0.1:27005); use an id no node has (see `rradiusd cluster members`), or stop the running node first
Joining with the same id would rewrite the address of that node in the cluster, so the program does not allow it. When you replace a host, either use a new id or stop the old node first.
Remove a node
Goal: take node 4 out of the cluster.
cluster remove checks these in order, and sends nothing when any check fails:
- The id has to be a positive integer:
the node id must be a positive integer, not 'abc', exit code 2. - The id has to be a member:
no node 9 in the cluster, exit code 1. - The node has to be stopped already: a node that is running cannot be removed.
- The number of voters left after the removal cannot be less than three unless you add
--force; leaving zero is always refused.
First try to remove it while node 4 is still running:
$ rradiusd cluster remove --config node1.toml 4
node 4 still answers at 127.0.0.1:27014: stop it first, then remove it
Exit code 2. A node that is removed but keeps running continues to answer with the old data it holds, so you must stop it first.
Stop node 4 (SIGTERM; it exits after 15 seconds on this machine), and then remove it:
$ rradiusd cluster remove --config node1.toml 4
removed node 4
$ rradiusd cluster members --config node1.toml
node 1 voter raft 127.0.0.1:27001 api 127.0.0.1:27011
node 2 voter raft 127.0.0.1:27002 api 127.0.0.1:27012
node 3 voter leader raft 127.0.0.1:27003 api 127.0.0.1:27013
When the removal would leave the cluster with only two voters:
$ rradiusd cluster remove --config node1.toml 3
removing node 3 leaves two voters, and the cluster stops writing when either stops; give --force to remove it anyway
$ rradiusd cluster remove --force --config node1.toml 3
removed node 3
$ rradiusd cluster members --config node1.toml
node 1 voter leader raft 127.0.0.1:27001 api 127.0.0.1:27011
node 2 voter raft 127.0.0.1:27002 api 127.0.0.1:27012
node 3 not in the cluster (listed in this configuration)
not in the cluster (listed in this configuration) means it is in the configuration and not in the cluster.
To add a removed node back, follow the conditions of Add a node: empty its data_dir and start it. Node 3 above came back into the cluster as a voter within 2 seconds after data3 was emptied and it was started.
Exit codes of cluster remove: 0 success; 1 there is no such member, or the cluster refused the removal; 2 a bad argument or configuration, or a check did not pass; 3 no answer within 30 seconds. With exit code 3 the removal may already have been done, and the message tells you to confirm with cluster members and not to simply run it again.
Why you must stop the node first
Measured on 2026-11-13, in Docker on one host, with three to four nodes:
- A node that was removed but is still running answers with old data. It no longer receives new writes, so an account added after the removal is rejected on it, and a disabled account can still log in. When the NAS still lists it as a RADIUS server, it gets wrong answers.
- Restarting with old data hangs, and logins get no answer.
- Restarting with the data emptied and the configuration still listing itself joins the cluster again automatically. So for a host you retire, turn the service off (for example
systemctl disable --now rradius), and do not only delete the data. - Management commands can hang. If the first node in the configuration is “removed but still running”, commands such as
userwait for the 30 second timeout; stopping it first avoids this.
Other notes
- Keep an odd number of nodes (3 or 5). 3 can lose 1, 5 can lose 2; 4 can lose only 1, the same as 3.
- It is the same when the node to remove is the leader: stop it first, the remaining nodes elect a new leader (writes during the election time out, see Across data centers), and then remove it.
- When a stopped host is first in the configuration,
cluster membersandcluster removefirst wait for it to time out before they try the next host. Each host is waited for at most 2 seconds in the program (PING_WAIT); the measurement on 2026-11-18 once saw about 5 seconds more, which was a version from before this value was changed. Delete the stopped node from the configuration, or move it to the end, and it does not happen. - When the majority is lost, the leader that
memberssees may be out of date. With three nodes, when only the former leader is left, it still reports itself as the leader (exit code 0), but it has no majority and writes do not succeed; when the remaining node is a follower,membersexits with exit code 3 after about 30 seconds. To judge whether you can write, look atHas a leaderinrradiusd status, or just try one write (measured on 2026-11-18). - Stopping one node does not require removing it. After an upgrade, a reboot or a hardware change, it comes back with the same
node_id; see Restarting nodes and rebuilding data. Removal is for nodes that will not come back. - What was tested: 2026-11-13 and 2026-11-18, Docker on one host, three to five nodes: removing the leader finished in about 5 seconds, during which logins to the remaining three every 0.05 seconds, about 1,480 of them, all succeeded, with a longest gap of 0.1 seconds (logins read the local copy and do not need a leader); adding a fourth node made it a voter in 1 to 3 seconds and it answered logins after about 4 seconds; adding and removing during writes, 394 writes did not fail. It was not tested on several physical hosts or through WireGuard, and the behavior of a real NAS during an election was not tested.
Check the settings of each node
The settings of the nodes should differ only in the local values. config diff compares two configurations (including defaults) and lists the differences; the two keys that are meant to differ, cluster.node_id and cluster.listen, are listed at the end under node-specific::
$ rradiusd config diff node1.toml node2.toml
cluster.data_dir: "data1" | "data2"
cluster.stop_without_leader_ms: 10000 | (absent)
metrics.port: 27041 | 27042
radius.accounting_spool.dir: "spool1" | "spool2"
radius.acct_port: 27031 | 27032
radius.auth_port: 27021 | 27022
tacacs.port: 27051 | 27052
node-specific:
cluster.node_id: 1 | 2
This is the result of the one-machine practice, where ports and directories all differ. With several hosts there are far fewer differences, for example two nodes of the ha-cluster scenario:
$ rradiusd config diff node1.toml node2.toml
metrics.bind: "10.99.0.1" | "10.99.0.2"
node-specific:
cluster.listen: "10.99.0.1" | "10.99.0.2"
cluster.node_id: 1 | 2
The exit code is 1 when there are differences, and 0 when they are exactly the same (differing only in node-specific). After you change the configuration and before you push it to the nodes, use it to confirm that you did not change only one machine. Secrets are shown only as differs (hidden), and their content is never printed.
See the state of the whole cluster
status --cluster asks the cluster for the member list and reads the metrics port of every member at the same time, one line per node:
$ rradiusd status --cluster --config node1.toml
rradius cluster status over 1.0 s, members from the cluster
node role ready auth/s acct/s discarded/s in progress address
1 leader ok 0.0 0.0 0.0 0 127.0.0.1:27041
2 leader ok 0.0 0.0 0.0 0 127.0.0.1:27041
3 leader ok 0.0 0.0 0.0 0 127.0.0.1:27041
total 3/3 0.0 0.0 0.0 0
This output is wrong, and wrong as expected: all three lines are node 1. The reason is that status --cluster reads the other members with the host name of each member’s api address, plus this node’s own metrics port. All three nodes are on 127.0.0.1 and their metrics ports differ, so all three lines read 127.0.0.1:27041.
For it to be correct in production, every node has to:
- use the same
[metrics] port; - set
[metrics] bindto an address the other nodes can reach, which is the host of theapiaddress.
A member that cannot be read is shown as unreachable, with the reason and the hint every node's [metrics] bind has to be an address this host can reach, on the same port as here below it.
Not verified on real hardware: the correct output of
status --clusteron several hosts. This chapter ran it on a single machine only, with the result above.
--cluster also works with --watch and --json. The fields of status are described in chapter 17.
Several hosts: the ha-cluster scenario
rradius-server/examples/scenarios/ha-cluster/ is an example for three hosts: node1.toml, node2.toml and node3.toml, which differ only in node_id, listen and [metrics] bind.
| Setting | Value | Why |
|---|---|---|
cluster.listen | each node’s WireGuard address 10.99.0.N | The Raft and API ports listen on the WireGuard interface only |
cluster.nodes | 10.99.0.1 to 10.99.0.3, ports 8100, 8200 | Every host uses the same ports |
cluster.migrations_wait_ms | 120000 | The time to wait for the other nodes when all three restart together |
lua.query_timeout_ms | 2000 | The total time a request waits for the database; the first write after the majority is lost still waits 30 seconds, and later ones fail at once and are written to the spool |
radius.bind | 0.0.0.0 | The NAS connects in from the physical network |
radius.clients | 10.80.0.0/16, the shared secret the same on all three | Every NAS configures all three nodes as RADIUS servers |
radius.status_server | true | NAS and load balancers use Status-Server to tell that a node is alive |
[radius.accounting_spool] | spool, at most 1 GiB | When the majority is lost, accounting is written locally first |
metrics.bind | each node’s WireGuard address, port 9812 | Monitoring scrapes from the internal network; the three use the same port so that status --cluster can read them |
log.format | json | Easy to collect centrally |
Copy the scenario to a working directory as described in chapter 03 and change dictionary to the absolute path of the dictionary, and all three pass check (with warnings about the example’s public secrets and file permissions):
$ for n in 1 2 3; do rradiusd check --config node$n.toml; done 2>&1 | grep -v WARN
configuration ok
configuration ok
configuration ok
check does not open any port, so it can also run on a machine that has no 10.99.0.x address. To really run it, you need three hosts and WireGuard.
Not verified on real hardware: how the ha-cluster scenario actually runs on three hosts connected through WireGuard. The behavior in this chapter was all verified on one machine with configurations whose ports were changed.
When you deploy, remember:
raft.secret,api.secretandnas.secrethave to be the same on the three hosts. Replace them with values you generate yourself withopenssl rand -hex 32, with permissions 0600.migrations/2_demo_users.sqlholds the demo accounts, and in production you delete it.- The NAS configures all three nodes as servers. When
stop_without_leader_msis set, a node that is cut off stops answering, and the NAS asks another one. - RADIUS uses the node’s physical address, not the WireGuard address; requests also have to come from a network in
radius.clients, or there is no answer. When the host you manage from is not in that network, temporarily add a[[radius.clients]]with only its address, test after a reload, and remove it when you are done. - With EAP, one login has to finish on the same node: configure the NAS for primary and backup, or let the load balancer pin the node by source (chapter 11).
- When one node starts first and the others have not, it waits until a majority has gathered (for at most
migrations_wait_ms). That is waiting, not a failure; it can serve only after the log showsRADIUS Server listening. - Set every node to restart automatically (
Restart=on-failureof systemd,restart: unless-stoppedof Docker), because in some situations the server exits on its own with exit code 1 so that the process manager restarts it (see After a forced stop).
Deploy with Docker Compose
compose.cluster.yaml in the root of the source starts three nodes on one Docker host, and the configuration files are docker/config/cluster/node1.toml to node3.toml:
| Item | Content |
|---|---|
| Services | node1, node2, node3, image rradius-server, built from the Dockerfile of the source |
| RADIUS ports | Host ports 1812/1813, 2812/2813, 3812/3813 map to 1812/1813 (UDP) of each container |
| Configuration | ./docker/config mounted read-only at /etc/rradius |
| Data | One volume per node: data1, data2, data3, mounted at /var/lib/rradius |
| Secrets | Compose secrets: docker/secrets/raft.secret, api.secret, radius.secret, mounted at /run/secrets/ |
| Security | Read-only root file system, cap_drop: ALL, no-new-privileges |
| Stop | stop_grace_period: 30s, restart: unless-stopped |
The main points of the node configuration:
- The three files differ only in
node_id. listen = "0.0.0.0": the container has only one address, and the other containers have to be able to reach it.nodesuses the service names:node1:8100,node1:8200, and so on.migrations_dir = "../migrations", that isdocker/config/migrations/.[metrics]listens on127.0.0.1:9812inside the container, forstatusinside the container.
The steps to start (the comment at the top of compose.cluster.yaml):
$ sh docker/init-secrets.sh
$ docker compose -f compose.cluster.yaml up --build
init-secrets.sh generates three random secret files, and does not overwrite ones that exist. To look at the state inside a container:
$ docker compose -f compose.cluster.yaml exec node1 rradiusd status --config /etc/rradius/cluster/node1.toml
$ docker compose -f compose.cluster.yaml exec node1 rradiusd cluster members --config /etc/rradius/cluster/node1.toml
For the exercise of stopping the leader, use docker compose -f compose.cluster.yaml stop node1 (it sends SIGTERM and waits at most 30 seconds).
What this book verified: after making a copy in a working directory and generating the secrets with init-secrets.sh, docker compose -f compose.cluster.yaml config passes; with the dictionary and secret paths of the three node configurations replaced by local paths, check passes for all.
Not verified on real hardware: actually building the image with
compose.cluster.yaml, starting three containers and stopping the leader. Theexeccommands above were not actually run. The behavior of a single node is the same as in the earlier exercises of this chapter, because the container runs the same program.
Note: The three containers are on the same Docker host, and when this host stops, the whole cluster stops. It suits tests and small setups; to survive a host failure, spread the nodes over different hosts, as the ha-cluster scenario does.
[metrics]listens only on the address inside the container, sostatus --clusterinside a container cannot read the other nodes.
Deploy on Kubernetes
deploy/kubernetes/ runs three nodes with a StatefulSet, applied with kubectl apply -k deploy/kubernetes. The files:
| File | Content |
|---|---|
kustomization.yaml | Applies statefulset.yaml, services.yaml and pdb.yaml; generates config/ into the ConfigMap rradius-config |
statefulset.yaml | 3 pods rradius-0 to rradius-2, podManagementPolicy: Parallel, one 1Gi PVC per pod |
services.yaml | The headless Service rradius-cluster (nodes find each other); the LoadBalancer Service rradius (for the NAS) |
pdb.yaml | PodDisruptionBudget maxUnavailable: 1 |
config/rradius-0.toml to rradius-2.toml | One per pod, differing only in node_id: pod rradius-N is node N+1 |
config/auth.lua, config/1_schema.sql | The script and the migration |
secret.example.yaml | What the Secret rradius-secrets looks like; it is not applied |
networkpolicy.yaml | Not applied by default: the RADIUS ports are open to the outside, the cluster ports only to the other nodes, the metrics port only to the monitoring namespace |
hostnetwork-patch.yaml | Not applied by default: when there is no load balancer that keeps the source address, lets the pod use the node’s network |
Build and load the image
statefulset.yaml uses rradius-server:latest with imagePullPolicy: IfNotPresent. Build it in the root of the source:
$ docker build -t rradius-server:latest .
The Kubernetes built into Docker Desktop and OrbStack: uses the local image directly, and you need not do anything else.
kind:
kind load docker-image rradius-server:latestloads the image into the kind nodes.Production: push it to your own registry, then enable the commented-out
imagesinkustomization.yamland change it to that name and version:images: - name: rradiusd newName: registry.example.com/rradius-server newTag: "1.0"
Create the Secret first
$ kubectl create secret generic rradius-secrets \
--from-literal=raft="$(openssl rand -hex 32)" \
--from-literal=api="$(openssl rand -hex 32)" \
--from-literal=radius="<your NAS shared secret>"
The Secret is mounted at /run/secrets/rradius, and the configuration reads it with paths such as secret_raft_file = "/run/secrets/rradius/raft". The three pods use the same Secret, so the cluster secrets are the same by construction. Replace radius with the shared secret your NAS actually uses. The example directory holds no real secrets, and secret.example.yaml only explains the format.
Apply and wait
First change [[radius.clients]] address in config/rradius-0.toml to rradius-2.toml from the documentation network 192.0.2.0/24 to the network of your NAS (the same in all three; for the reason see Change the NAS addresses), then:
$ kubectl apply -k deploy/kubernetes
$ kubectl rollout status statefulset/rradius
The three pods start together and begin to serve after a leader is elected; rollout status ends when all three are ready. Then add accounts as described in Run commands in a pod.
Why the example is designed this way
Every point corresponds to a behavior described earlier in this chapter:
podManagementPolicy: Parallel: the three pods start together. A node serves only after a majority has gathered, and if they started one by one, the first would wait forever.publishNotReadyAddresses: true(headless Service): pods that are not ready yet keep their DNS names. Otherwise nodes that are waiting for a leader cannot find each other, and no leader can be elected.nodesuses DNS names: in the formrradius-0.rradius-cluster:8100;listen = "0.0.0.0", because the other pods connect through the pod address.- Probes: the metrics port opens only after the node has caught up with the cluster, so only the
startupProberuns first (/livez, every 5 seconds, at most 60 times). After that thelivenessProbelooks at/livezand thereadinessProbeat/readyz. stop_without_leader_ms = 10000: a pod that is cut off stops answering and/readyzbecomes 503, so the Service does not send the NAS traffic to it.ready_delay_msdefaults to 5000: after SIGTERM/readyzreturns 503 first, the Service moves the traffic away first, and only then does the pod stop accepting requests.terminationGracePeriodSeconds: 30covers the whole shutdown.externalTrafficPolicy: Local: rradius tells NAS apart by source address, and the source address has to reach the pod unchanged.- PodDisruptionBudget
maxUnavailable: 1: for voluntary disruptions such as draining a Kubernetes node, only one pod is moved at a time and two of three stay, which keeps the majority. [metrics] bind = "0.0.0.0": the kubelet probes from the pod address. The three pods use the same port 9812, so by the program’s rulesstatus --clustershould be able to read the other members; afternetworkpolicy.yamlis applied, 9812 is open only to themonitoringnamespace, and the pods can no longer read each other.
Change the NAS addresses
[[radius.clients]] in config/rradius-*.toml is the documentation network 192.0.2.0/24, and you have to change it to the actual addresses of your NAS. Do not write a network that is too large: if the network also covers the addresses of the Kubernetes nodes, packets whose source address was changed by the load balancer are also accepted, and all NAS are treated as the same client.
Verify that the source address is not rewritten
When packets pass through a Kubernetes Service, the source address is often changed to the address of a node or a gateway, with one of two results:
- The rewritten address is not in the network of any client: rradius does not recognize it and does not answer, counts it in
rradius_radius_discarded_total{reason="unknown_client"}, and the log (rate limited) saysRADIUS packet from unknown client <address> discarded. - The rewritten address happens to fall in the network of some client, for example when a client uses a wide network such as
10.0.0.0/8: the request is accepted anyway and everything looks normal, but all NAS are treated as the same client. In this case no counter increases, and you can only see it in the authentication records.
So always verify after applying: send one request from a NAS and look in the authentication record (log.auth, on by default) to see whether source= is the address of that NAS. The request may go to any pod, so look at all three:
$ kubectl logs rradius-0 | grep rradius_auth | tail -3
… INFO rradius_auth: authentication protocol="radius" client="192.0.2.0/24" source=192.0.2.10 user="alice" …
If source= is the address of a node, a gateway or the pod network, it has been rewritten. When there are no records at all, look at whether unknown_client increases:
$ kubectl port-forward pod/rradius-0 9812:9812 &
$ curl -s localhost:9812/metrics | grep 'reason="unknown_client"'
- Most cloud load balancers support
externalTrafficPolicy: Local, but some UDP load balancers rewrite the source address themselves, so read the documentation of the cloud. - For packets sent from a Mac to a LoadBalancer in the Kubernetes built into OrbStack,
source=is the gateway of the pod network, so you cannot verify on OrbStack whether the source address is kept. For trying it out locally, you can temporarily change the client to that address.
Not verified on real hardware: the behavior of the two kinds of load balancers above is written from the comments in
deploy/kubernetes/of the source and the general behavior of Kubernetes. This book did not measure it on a real cluster.
Without a suitable load balancer: hostNetwork
hostnetwork-patch.yaml lets the pods use the node’s network directly. The NAS packets go to the node’s address, and the source address is not rewritten. Enable patches in kustomization.yaml:
patches:
- path: hostnetwork-patch.yaml
- The patch sets
podAntiAffinity, so one node can hold only one rradius pod, and you need at least three Kubernetes nodes. - The NAS is configured with the addresses of the three nodes, as primary and backup or in rotation, either way.
- When a pod moves to another node its address changes, and the NAS side has to be changed to follow, so it suits fixed nodes, for example pinned with
nodeSelector. - The metrics port and the cluster ports open on every address of the node, including the public ones. The example has
[metrics] bind = "0.0.0.0", so 9812 is then open to the outside without authentication and without TLS; the cluster ports 8100 and 8200 are the same. NetworkPolicy has no control over pods that use hostNetwork, sonetworkpolicy.yamlcannot stop this. Use the node’s firewall to let only the internal network reach 9812, 8100 and 8200, or change[metrics] bindto the node’s internal address (the addresses of the three nodes differ, so the configuration files no longer differ only innode_id).
TACACS+
When the configuration adds [tacacs], add a TCP container port to statefulset.yaml, and enable the commented-out tacacs part of services.yaml. TCP through externalTrafficPolicy: Local also keeps the source address, and the verification method is the same as above.
Note: The container runs as uid 10001 with all capabilities dropped, and whether it can bind a low port such as 49 depends on how the container runtime handles low ports; this book did not verify it. The safe way is to set the
portof[tacacs]to 1024 or above (for example49490), keep theportof the Service at 49, and lettargetPortpoint at that port.
Probes and latency
The metrics port ([metrics] bind = "0.0.0.0", because the kubelet probes the pod address from the node) has two paths; for the details see chapter 17:
| Path | 200 | 503 | Use in the example |
|---|---|---|---|
/livez | The process responds | Never | startupProbe, livenessProbe |
/readyz | Can answer authentication | Stopping (SIGTERM received); stop_without_leader_ms is set and there has been no leader for longer than that; or an external database with required_for_ready cannot be reached (content database <name> unreachable, chapter 09) | readinessProbe |
- A pod that is not ready is taken out of the
rradiusService, and the NAS requests go to the other pods. The example setsstop_without_leader_ms = 10000: when one of three is left, the remaining one stops answering after about 10 seconds and becomes not ready;/livezstays 200 and the container is not restarted. - When a pod is deleted or updated, the kubelet sends SIGTERM and
/readyzbecomes 503 at once. The pod keeps answering as usual for 5 seconds (the defaultready_delay_msof a three-node cluster), and thereadinessProberuns every 5 seconds and takes it out after 1 failure, so the Service stops sending requests first, and only then does the pod stop accepting, wait for the requests in progress and exit. The whole process takes about 15 seconds, withinterminationGracePeriodSeconds: 30. - Without
stop_without_leader_ms,/readyzis always 200 except while stopping: a node without a leader still answers read-only logins from the local copy, and taking it out of the Service would make all logins fail instead. - The
startupProbewaits at most 5 minutes (every 5 seconds, at most 60 times): the metrics port opens only after the node has caught up with the cluster, and that needs a leader first. Without thestartupProbe, thelivenessProberestarts the container before a leader is elected.
Run commands in a pod
$ kubectl exec -i rradius-0 -- rradiusd user add --config /etc/rradius/rradius-0.toml alice
$ kubectl exec rradius-0 -- rradiusd cluster members --config /etc/rradius/rradius-0.toml
$ kubectl exec rradius-0 -- rradiusd status --cluster --config /etc/rradius/rradius-0.toml
user add reads the password from standard input, so it needs -i. For how to apply a changed configuration (the ConfigMap changes its name, pods restart one by one), and what to change when you add a migration, see chapter 18.
What this book verified: after making a copy in a working directory, kubectl kustomize can generate the ConfigMap, 2 Services, the PodDisruptionBudget and the StatefulSet; with the dictionary and secret paths of the three rradius-*.toml replaced by local paths, check passes for all.
Not verified on real hardware: actually applying to a Kubernetes cluster, the start of the pods, deleting the leader pod, and the effect of
hostnetwork-patch.yamlandnetworkpolicy.yaml. Thekubectl execcommands above were not actually run.
Across data centers
What happens to the cluster when the three nodes are in different data centers, with a few to a few dozen milliseconds between the nodes? The numbers in this section were simulated on one host, and they are for judging “is it worth designing in this direction”, not a promise for a real wide-area network. Measurements without a date were carried over from the old manual and were not measured again; those with a date were measured on that day. The raw numbers and the measurement scripts are not in this repository.
Test conditions
- Environment: one host with an Apple M4 Max (14 cores), Docker on OrbStack, one container per node; the image is the core
rradius-serverplusiproute2. The node configuration isdocker/config/auth.luaand thesqlhandler (logins read the local copy, and every accounting packet makes oneINSERT). - How the delay was added:
tc netemadds a one-way delay (half of the round-trip time, RTT) on the egress of every node toward the other two nodes, and the path from the RADIUS client to the nodes gets none. The RTT was calibrated withpingbetween the nodes, and the tables below always use the measured value. - Limits of the simulation: only a fixed delay, with no jitter, no packet loss, and the same in both directions; the nodes are on the same host, and CPU and memory are not the bottleneck.
- Load:
rradius-bench, fixed concurrency 64, 2 seconds of warm-up and 10 seconds of measurement, 3 runs for each RTT point. The read load ispaplogins (reading the local copy); the write load isacct-start(every packet makes oneINSERT INTO accounting, which has to go through Raft). The client hits the leader of that time.
Steady state: reads are not affected, writes are roughly inversely proportional to RTT
| RTT between nodes (measured) | Login (read) throughput | Login p50/p99 | Accounting Start (write) throughput | Write p50/p99 |
|---|---|---|---|---|
| 0.2 ms | 86,100/s | 0.7/1.4 ms | 42,700/s | 1.3/3.3 ms |
| 5.1 ms | 85,800/s | 0.7/1.5 ms | 3,940/s | 14.6/25.6 ms |
| 19.2 ms | 85,200/s | 0.7/1.5 ms | 826/s | 78/119 ms |
| 50.5 ms | 85,300/s | 0.7/1.6 ms | 318/s | 198/309 ms |
- Reads do not change with RTT: they read the local copy and do not use the network.
- At fixed concurrency, write throughput is roughly inversely proportional to RTT: throughput times RTT is about 20,000, 15,900 and 16,100 at 5, 19 and 50 ms; the latency of one write is about 2.9, 4.1 and 3.9 times the RTT. That is, at concurrency 64, the write limit is about
64 ÷ (4 × RTT). For more you have to add concurrency, which was not tested. - These write throughputs were measured against the leader; the throughput of sending writes to a follower (which has to forward them to the leader first) was not measured.
Kill the leader
The leader was killed with docker kill (SIGKILL), and the client sent a writing accounting Start to a surviving node every 50 ms. The election time is from the kill until rradius_cluster_is_leader of one of the surviving nodes becomes 1; the write unavailable time is from the kill until the first write sent after it gets a response.
The table below is the measurement from before the reconnect interval was patched, 5 runs per point:
| RTT between nodes (measured) | Election time | Write unavailable time |
|---|---|---|
| 0.15 ms | 5.7–6.9 s | 6.7–15.2 s (about 15 s in 4 of 5 runs) |
| 5.2 ms | 5.0–6.4 s | 10.1–15.2 s |
| 20.0 ms | 6.0–6.9 s | 7.2–17.6 s |
| 50.1 ms | 6.4–6.8 s | 7.4–17.8 s |
- The election time is about 5 to 7 seconds, and within the measured range it does not depend on RTT.
- Writes recover a little later than the election. The reason: the client of the cluster database (hiqlite 0.16) caches “who the current leader is” and updates it only in the reconnect loop; the original reconnect interval was 1 second for the first 5 attempts and 5 seconds after that, so when the election finished after the 5th second, it waited another 5 seconds. Now rradius loads a modified hiqlite (
vendor/hiqlite) that changes the 5 seconds to 1 second (RECONNECT_SLOW_INTERVAL; the change is recorded inMODIFICATIONSin that directory), so it reconnects every second; during this time the node logs one line per second,Could not connect Client API WebSocket to node1(the old leader). This interval is an internal constant of hiqlite and there is no setting to adjust it. - Measured on 2026-11-23 (three nodes, Docker on one host, RTT 0, leader stopped): the election took 6.3 to 6.7 seconds, and the first successful write came at 7.2 to 7.5 seconds, that is about 0.5 to 1 second after the election; under the same conditions the version from before the change took 15.1 to 15.5 seconds (3 runs). So the write interruption measured on one machine is about 7 to 8 seconds (the election about 6 to 7 seconds, plus the client reconnecting). Each was measured only 3 times, only on single-host Docker with RTT about 0; wide-area networks and longer elections were not measured.
- When you plan for several data centers, you can take about 20 seconds as the margin for the write interruption. This number comes from the 15 to 18 seconds before the change in the table above, was not measured on the version after the change or on a wide-area network, and is a conservative estimate, not an expected value.
- Logins (reads) are not affected and still read the local copy.
Partition
netem dropped all packets between the nodes (in both directions), and the path of the RADIUS client was not affected. Each case was run once, with samples about 5, 12, 22 and 32 seconds after the partition; each time one pap and one accounting Start (timeout 2 seconds) were sent to every node. The results for RTT 0.2 and 20 ms were the same unless noted.
| Case | The isolated node | The majority side | Recovery (after the network is reconnected) |
|---|---|---|---|
| One follower isolated | Logins are answered as usual (reading the old copy); accounting gets no answer; within about 10 seconds rradius_cluster_leader becomes 0 and seconds_without_leader keeps rising; applied_index stops | Only the leader answers accounting (at 0.2 ms both nodes answered; at 20 ms the other node did not answer in 4 samples); logins are normal | Caught up in 24.8 s (0.2 ms) and 29.3 s (20 ms) |
| Leader isolated | Logins are answered as usual; accounting gets no answer; rradius_cluster_is_leader is still 1, but rradius_cluster_leader becomes 0 after about 10 seconds; applied_index stops | A new leader is elected (visible in the sample at the 12th second at 0.2 ms and the 22nd second at 20 ms); accounting still got no answer in the sample at 32 seconds (including from the new leader); logins are normal | Caught up in 1.3 s (0.2 ms) and 1.6 s (20 ms); the old leader becomes a follower |
- The isolated node’s copy stays at the state of the moment of the partition and still answers logins. If you cannot accept that, set
stop_without_leader_ms(it was not set this time, and the behavior with it set was not tested). - Accounting writes on the majority side took very long to recover after the leader changed; this time they had not recovered 32 seconds after the partition. It may have the same cause as killing the leader above, but in a partition the old leader was still alive, and this was not verified.
Recovery time after isolating a follower (Linux, no need to tune tcp_retries2): both the connection between Raft nodes (port 8100) and the API connection have TCP_USER_TIMEOUT set to 10 seconds: when data was sent and no acknowledgment came for 10 seconds, the kernel closes the connection, and then it reconnects. Without this setting, a connection that got no response during the isolation doubles its retransmit interval each time, and after reconnection it has to wait for the next retransmit before it can send, so the recovery time grows with how long the isolation lasted. On 2026-11-25 the same three-node Docker environment (RTT 0) was used to measure “from reconnection until this node knows the leader, has caught up with the data and a write through it gets a response”, the median of 3 runs each:
| Isolation time | Without this setting (2026-11-24, 1 run each) | With this setting (3 runs each) |
|---|---|---|
| 12 seconds | 15.3 s | 6.4 s (5.1 to 6.4) |
| 30 seconds | 29.4 s | 6.4 s (5.1 to 8.2) |
| 60 seconds | 47.3 s | 4.0 s (3.7 to 4.5) |
However long the isolation, recovery is within 10 seconds. The data to catch up was only 3 to 12 entries, so the synchronization is not slow. This setting takes effect only on Linux, and other systems keep the previous behavior.
With 100 ms RTT between the nodes and 5% packet loss on every packet, without isolating, writing continuously for 5 minutes (accounting Start, concurrency 16), the difference with and without this setting: throughput 30.2/s against 29.7/s, the leader did not change, and there was no Raft WebSocket stream ended log, so this value did not cause a connection to be wrongly judged as down. Worse networks (loss lasting more than 10 seconds, a long total outage) were not measured; in those cases it is expected that the connection is closed, and it reconnects after recovery.
History (2026-11-20, the version without TCP_USER_TIMEOUT, 1 run each): with isolation of 4, 12, 30 and 60 seconds, recovery took 4.9, 15.2, 25.5 and 49.8 seconds; after lowering net.ipv4.tcp_retries2 of the nodes from 15 to 5, recovery after 12, 30 and 60 seconds of isolation became 5.1, 7.6 and 5.1 seconds. The current version does not need this kernel parameter to be tuned.
Rolling upgrade
First measure the highest write throughput at that RTT, take half of it, and divide it equally among the three nodes, with one rradius-bench per node (acct-start, fixed rate, timeout 1 second, no retransmit); in addition every node has a write probe every 50 ms. One node at a time (the two followers first, the leader last), run docker stop -t 30 and docker start, and wait until the log shows cluster node N has caught up with the cluster.
| RTT between nodes (measured) | Load (total) | Stop to caught up, per node | The stop itself | Requests that timed out | Longest gap on the other nodes during the upgrade |
|---|---|---|---|---|---|
| 0.2 ms | 21,600/s | 15.9, 17.6, 21.3 s (leader last) | 14.6 s | 5,500–6,500 per node, about 0.2–0.3% | 0.1–1.4 s |
| 19.8 ms | 350/s | 17.1, 17.1, 21.5 s (leader last) | 14.8 s | 1,500–2,600 per node, about 3.6–6.2% | 0.1–6.9 s (6.9 when the leader was stopped) |
- Upgrading one node at a time, the other two keep answering. Most of the requests that timed out were sent to the node being stopped (the client did not switch to another node).
- The executables of the core edition and the enterprise edition have the same name (
rradiusd), so when you change versions you only replace that file, and you confirm withrradiusd --versionwhich version each node is. A cluster with nodes of two different versions at the same time was not tested for this manual and is not guaranteed to work; if you need to do it, try it first on a test cluster. - Upgrading one node takes about 16 to 21 seconds (about 15 seconds to stop, plus the start and catching up), and the leader takes the longest; when the leader is stopped, the write gap on the other nodes is the longest.
- Not tested: old and new versions mixed (this time the same image was restarted), and the catch-up time with a large amount of data.
Three topologies
| A single cluster across three data centers | A main cluster plus a cold standby | An independent cluster in each data center | |
|---|---|---|---|
| How | The three nodes are spread over three data centers, in one cluster | One data center runs the cluster; the other normally has no nodes, and uses [cluster.backup] of the enterprise edition (chapter 01) to save a copy regularly, and when something happens restores the copy as a new cluster | Each data center has a three-node cluster, unrelated to the others |
| Login (read) | Not affected (0.7 ms measured) | Same as the main cluster | Same as a single data center |
| Write (IP allocation, verification codes, accounting) | About 3 to 4 RTT each; at concurrency 64, about 830/s at 20 ms and about 320/s at 50 ms | Same as a single data center | Same as a single data center |
| One data center loses contact entirely | The other two data centers have a majority; the election takes about 5 to 7 seconds, and you have to allow a margin for the write interruption (see above) | When the main data center is lost you depend on a restore, and writes after the last copy are lost; the switch needs a person | The other data centers are not affected; the users of the lost data center have to be served elsewhere |
| Cost | Writes are slow and the gaps during upgrades grow; you have to check yourself how much worse the real network is than the simulation | The standby data center has no hot data normally; how long a restore takes was not measured | Accounts, settings and migrations have to be done once in each cluster, and you manage the consistency yourself |
A hot standby cannot be done at present. Keeping a node in the standby data center that only replicates and does not vote (a learner) needs a new node to stay a learner; now a new node is a learner first and is promoted to voter automatically when it has finished copying, and there is no setting that makes it stay a learner.
What was not tested
Jitter and packet loss, different delays in the two directions, physical hosts and environments through WireGuard, the retransmit behavior of a real NAS during an election, the throughput of sending writes to a follower, higher concurrency, five nodes, a partition with stop_without_leader_ms set, the behavior of the accounting spool under high latency, partitions longer than 30 seconds, and the time a backup restore takes.
Cluster metrics
The /metrics of every node has these, and the values are this node’s own view:
| Metric | Type | Meaning |
|---|---|---|
rradius_cluster_leader | gauge | 1 means there is a leader that can be written to |
rradius_cluster_is_leader | gauge | 1 means this node is the leader |
rradius_cluster_applied_index | gauge | The number of the Raft log entry the local copy has applied |
rradius_cluster_seconds_without_leader | gauge | How many seconds there has been no leader; 0 when there is a leader |
rradius_cluster_caught_up | gauge | 1 means it has caught up with the cluster since startup; 0 means it is serving from a copy that may be behind |
rradius_db_batched_writes_total | counter | Script writes committed in one transaction together with other writes |
rradius_db_split_batches_total | counter | How many times a combined transaction failed and was split to find the statement that failed |
rradius_radius_discarded_total{reason="no_leader"} | counter | Requests not answered because of stop_without_leader_ms |
rradius_radius_discarded_total{reason="database"} | counter | Requests not answered because the database could not be used (for example a write failed) |
Suggested directions for alerts:
- Across the whole cluster, the sum of
rradius_cluster_is_leadershould be 1. 0 means there is no leader. rradius_cluster_seconds_without_leaderstays above 0.- The
rradius_cluster_applied_indexof a node stays behind the other nodes. rradius_cluster_caught_upis 0 for too long.- The bytes of the accounting spool (
rradius_acct_spool_bytes) keep growing, which means writes to the database are failing.
The deploy/monitoring/ directory of the source has ready-made rules; see chapter 17. The full description of every metric is in Appendix C.
Common mistakes
Symptom: check prints cluster.nodes: node 1 is required.
Cause: There is no node with id 1 in [[cluster.nodes]].
Fix: Number the node ids from 1.
Symptom: check prints cluster.node_id 4 is not in cluster.nodes.
Cause: The node_id of this node is not listed in its own configuration.
Fix: Add its own entry to [[cluster.nodes]].
Symptom: check prints cluster.secret_raft must be at least 16 characters, or exactly one of cluster.secret_api or cluster.secret_api_file must be set.
Cause: The cluster secret is too short, or both ways of writing it were given, or neither.
Fix: Generate it with openssl rand -hex 32 > raft.secret and write only secret_raft_file in the configuration.
Symptom: check or startup warns cluster.listen is not set, so the cluster's Raft and API ports are on all interfaces, ….
Cause: There is [[cluster.nodes]] but no listen.
Fix: Set it to the node’s internal or WireGuard address; if you really want to listen on all addresses, write listen = "0.0.0.0".
Symptom: The logs of the second and third node have many ERROR hiqlite::init: … Raft is not initialized or Connection refused at the beginning.
Cause: Node 1 has not created the cluster yet, or the other nodes have not started.
Fix: Wait. When has caught up with the cluster appears, it is fine. If it never appears, confirm that all three nodes have started and that the raft and api addresses can reach each other.
Symptom: The node exits after starting and prints not ready to apply migrations: node 2 did not join within 10s (the limit is migrations_wait_ms; raise it if a migration file takes longer), exit code 1.
Cause: A majority could not gather within migrations_wait_ms: the other nodes are not running, or cannot be reached.
Fix: Bring the other nodes up first; when you restart together, set migrations_wait_ms longer.
Symptom: At startup it prints cannot start cluster node 2: node id 2 is in use: …, exit code 2.
Cause: A node with a different address in the cluster already uses this id and is still running.
Fix: Use an id nobody uses (look at cluster members first), or stop that node first.
Symptom: cluster members or status --cluster prints 127.0.0.1:27011 refused the api secret: [cluster] secret_api differs from the cluster's, exit code 2.
Cause: The API secret of this configuration differs from the cluster’s.
Fix: Use the same api.secret as the cluster.
Symptom: cluster members hangs for 30 seconds and prints the cluster did not answer within 30 s, exit code 3.
Cause: None of the nodes in the configuration answers, or none has a leader.
Fix: Confirm that the nodes are running and the API ports can be reached; when the majority is lost, bring the nodes back first.
Symptom: cluster remove prints node 4 still answers at 127.0.0.1:27014: stop it first, then remove it.
Cause: The node to remove is still running.
Fix: Stop it first, then remove it.
Symptom: cluster remove prints removing node 3 leaves two voters, and the cluster stops writing when either stops; give --force to remove it anyway.
Cause: Only two voters would remain after the removal.
Fix: Add a new node first and then remove the old one; add --force only when you are sure you want to shrink to two nodes.
Symptom: /readyz of a node returns 503 no leader, logins get no answer, and Discarded: no leader increases.
Cause: stop_without_leader_ms is set, and this node has had no leader for longer than that.
Fix: Let it reconnect to the other nodes, or bring the stopped nodes back. /livez is still 200, so do not restart it because of this.
Symptom: Every line of status --cluster has the same address, or other nodes show unreachable.
Cause: The metrics ports of the nodes differ, or [metrics] bind is an address other hosts cannot reach.
Fix: Give every node the same metrics port, and set bind to the host of the api address.
Symptom: A node that was killed warns Node did not shut down gracefully - auto-rebuilding State Machine when it starts.
Cause: It was not shut down cleanly last time.
Fix: Nothing to do; it rebuilds itself. After that, stop it with SIGTERM and give it enough time.
Symptom: On Kubernetes a pod never becomes ready and the startupProbe fails.
Cause: No leader can be elected: the other pods did not start, the raft or api secrets differ, or rradius-cluster has no publishNotReadyAddresses.
Fix: Look at the reason with kubectl logs; keep the secrets in the same Secret.
Symptom: On Kubernetes requests from the NAS get no answer, and unknown_client increases.
Cause: The source address was rewritten by the load balancer.
Fix: See Verify that the source address is not rewritten.
Symptom: The client= in the authentication records of different NAS is always the same, and source= is the address of a node or a gateway.
Cause: The source address was rewritten and happens to fall in the network of some client, so all NAS are treated as the same one.
Fix: The same as above; shrink [[radius.clients]] to the actual network of the NAS.
Symptom: All three pods are ready, but after one is stopped all requests get no answer for a while.
Cause: The stopped one was the leader, and the remaining two are still electing.
Fix: It recovers within seconds; if it lasts, look at rradius_cluster_leader.
Symptom: A newly added migration is not applied (Kubernetes).
Cause: The items of statefulset.yaml is missing that line, so the file does not appear in migrations/.
Fix: See chapter 18.