Configuration
By Roberto Arato of aratoingegneria.it
Every machine in the cluster, node or client, has a single file:
/etc/nexfs/nexfs.json. It is read by the nexfsd daemon, the
nexfs-client client, the nexfsctl tool and the libnexfs library; with
-c FILE you use a different one.
The file is JSON. An unknown key is an error, with a message that says which one and why: a misspelled name does not silently turn into the default value.
A complete example
The node node-1, which acts as a meta node and a data node, in a cluster
with three meta nodes:
{
"node": "node-1",
"id": 1,
"roles": ["meta", "data"],
"listen": {"address": "10.20.0.11", "port": 7400},
"meta": [
{"id": 1, "name": "node-1", "address": "10.20.0.11", "port": 7400},
{"id": 2, "name": "node-2", "address": "10.20.0.12", "port": 7400},
{"id": 3, "name": "node-3", "address": "10.20.0.13", "port": 7400}
],
"disks": ["/srv/nexfs/disk0", "/srv/nexfs/disk1"],
"admins": ["administrator"],
"tls": {
"ca": "/etc/nexfs/pki/ca.crt",
"cert": "/etc/nexfs/pki/node-1.crt",
"key": "/etc/nexfs/pki/node-1.key"
},
"state_dir": "/var/lib/nexfs",
"metadata_cache_mb": 256,
"log": {"level": "info"},
"encryption_key": "/etc/nexfs/blocks.key",
"scrub": {"rate_mb_s": 32, "interval_s": 604800},
"timeouts": {"request_ms": 8000, "replace_after_s": 600}
}
A client (a machine that only mounts) has just its name, no roles, the list of meta nodes and its certificates:
{
"node": "compute-7",
"id": 107,
"roles": [],
"meta": [
{"id": 1, "name": "node-1", "address": "10.20.0.11", "port": 7400},
{"id": 2, "name": "node-2", "address": "10.20.0.12", "port": 7400},
{"id": 3, "name": "node-3", "address": "10.20.0.13", "port": 7400}
],
"tls": {
"ca": "/etc/nexfs/pki/ca.crt",
"cert": "/etc/nexfs/pki/compute-7.crt",
"key": "/etc/nexfs/pki/compute-7.key"
}
}
The keys
Who the node is
| Key | Value | Notes |
|---|---|---|
node |
the node name | must be the name in its certificate: that is how the others recognize it |
id |
a number from 1 up | unique in the cluster |
roles |
list of "meta", "data", "witness" |
[]: client only |
listen |
{"address": IP, "port": N} |
where the daemon listens (default port in the commands: 7400); not needed by clients |
The roles:
- meta: holds a copy of the metadata and of the control store, and votes in the consensus group. A cluster has 1, 3 or 5 meta nodes: with three it keeps working if one shuts down, with five if two shut down.
- data: holds the file blocks on its disks.
- witness: votes and keeps the consensus log, but not the store. It is for a cluster with only two real meta nodes, to reach a majority with a small machine.
The cluster
| Key | Value | Notes |
|---|---|---|
meta |
list of meta nodes to contact: {"id", "name", "address", "port"}, and "witness": true for the witness |
from 1 to 5. It is enough for one to respond: meta nodes that joined later (nexfsctl meta add) are announced by the cluster, and there is no need to rewrite the other machines' files. Every program remembers them in the file next to it, nexfs.json.meta (one line per node), so it finds them even when the nodes in the file are down. A new cluster starts with 1, 3 or 5 |
admins |
list of certificate names | optional: who can administer besides the meta nodes (16 at most) |
Security
| Key | Value | Notes |
|---|---|---|
tls.ca |
the cluster's CA certificate | |
tls.cert, tls.key |
the node certificate and its key | with the systemd service, the key is passed to the daemon by systemd, and the daemon does not read it itself |
tls.ca_key |
the CA key, only on meta nodes that welcome new machines with an entry code (nexfs-setup) |
optional; written by nexfs-setup init and join --meta, and passed to the daemon by systemd like the others |
encryption_key |
absolute path of the block key | optional, data nodes only: 64 bytes, or 128 hexadecimal digits. It cannot be on a data disk: the check rejects it |
Disks and state
| Key | Value | Notes |
|---|---|---|
disks |
list of folders, one per disk | data nodes only; 16 at most. Each folder is the root of a mounted disk. Add one more disk with nexfsctl disk add DIR (Commands), which also updates the service: written by hand, the new folder would stay read-only for nexfsd (ProtectSystem=strict) |
state_dir |
folder | default /var/lib/nexfs: the consensus log and the metadata store |
metadata_cache_mb |
from 8 to 1,048,576 | default 256: the memory for the metadata cache, in MiB |
disk_reserve_mb |
from 0 to 1,048,576 | data nodes only; default: 2% of each disk, at least 1 GiB (on small disks, under 20 GiB, 5%). The space the blocks always leave free on a data disk: below it the node refuses new writes, and programs get "no space left on device" (ENOSPC), while deleting still works. It keeps the system and the state folder, often on the same disk, from filling up and stopping the node. 0 turns it off |
Maintenance
| Key | Value | Notes |
|---|---|---|
scrub.rate_mb_s |
from 0 to 65,536 | default 32: the maximum speed of the copy check, in MiB/s; 0 turns it off |
scrub.interval_s |
from 10 seconds to one year | default 604,800 (one week): how often it starts over; the first round starts ten minutes after startup |
timeouts.request_ms |
from 100 to 600,000 | default 8,000: how long a request waits before returning an error |
timeouts.replace_after_s |
from 20 to 604,800 | default 600: after how long the copies of a data node that does not respond are rebuilt elsewhere |
log.level |
error, warning, info, debug |
default info; messages go to the systemd journal |
When it changes
- The file is read again when the program starts: after a change, run
systemctl restart nexfsdon the node (the others keep working). - The number of copies is not in the file: it belongs to the cluster and
to the folders, and you change it while running with
nexfsctl copies(see Administration). - Administrators are defined on the meta nodes: that is where
"admins"must be written.