raftdb-server settings
Every setting of raftdb-server with its command-line, environment and file spelling, its default and its rules, and the three profiles.
Every setting has one name. The same name is used as --name VALUE on the command line, as RAFTDB_NAME in the environment (upper case, - becomes _) and as name = value in raftdb.conf. The file has key = value lines; a line that starts with # is a comment; a value may be wrapped in double quotes. See The programs for the order in which the sources win.
Syntax#
# raftdb.conf
profile = primary
dir = /var/lib/raftdb
addr = 0.0.0.0:7480
shards = 4
user = app:PASSWORD:readwrite@shopOptions#
General#
| Setting | Meaning | Default |
|---|---|---|
profile | single, primary or replica (see below). Only on the command line, in the environment as RAFTDB_PROFILE, or in the file. | single |
dir | Data directory. | /var/lib/raftdb or %ProgramData%\RaftDB if that folder exists, otherwise ./raftdb-data |
addr | HOST:PORT to listen on. The single profile refuses an address that is not loopback (127.0.0.1, localhost, [::1]). | 127.0.0.1:7480 for single, 0.0.0.0:7480 for the others |
shards | Number of shard threads per table. Every table of a server uses the same number. | The number of cores, at most 4 |
engine | memory (all data in RAM) or lsm (data may exceed RAM). Applies to tables created afterwards; existing tables keep their engine. | memory |
checkpoint-min-mb | At start, rewrite a shard log that is at least this big and mostly dead (more than twice the size of its live rows plus 64 KiB). 0 switches it off. | 8 |
seconds | Stop gracefully after this many seconds (tests and demos). | run until stopped |
studio | Folder of the Studio's static files; they are then served at /. | none |
Accounts and access#
| Setting | Meaning | Default |
|---|---|---|
user | NAME:PASSWORD[:ROLE[@DATABASE]], repeatable. ROLE is readonly, readwrite, admin or control. A password may contain :; the last part counts as a role only if it is one. @DATABASE limits the account to one database. | none |
token | A shared secret every client must send. Holders of the token are administrators everywhere. | none |
open | Serve with no login at all, and create no admin account. For a machine you fully trust. | false |
cors | An origin whose pages may call the API, repeatable. Never a substitute for authentication; * must not be used on an open server. | none |
control-peers | HOST:PORT that a node managed by a watcher may be told to follow, repeatable. Set it on every managed node: the node sends its replication credential to the address it is told to follow, so without a list an account with the control role can collect that credential by naming its own address. | none (any address) |
https-addr | HOST:PORT of an extra HTTPS listener for the HTTP API (the main port stays plain). | none |
https-cert, https-key | PEM certificate chain and private key for https-addr; without them a self-signed certificate is made at each start. | none |
allow-remote-servers | Let the Studio served by this server connect to other servers (adds http: and https: to the page's connect-src). | false |
With no token, no user and no open, the first start creates the admin account with a random password written to <dir>/admin.password (readable by its owner only where the platform allows) and read back at every later start. The primary profile also creates a read-only replicator account with its password in <dir>/replicator.password. user passwords on the command line are visible in the process list; prefer the file.
Replication and cluster#
| Setting | Meaning | Default |
|---|---|---|
replica-of | HOST:PORT of the primary to copy. Required by the replica profile. Cannot be combined with control. | none |
replica-user | NAME:PASSWORD the node uses to read its primary (and, on a managed node, the leader). | none |
replica-token | A token for the primary, as an alternative. | none |
sync-replicas | How many replicas must confirm a write before it is acknowledged. 0 is asynchronous. | 0 |
sync-timeout-ms | How long a write waits for them before it is acknowledged anyway (and counted as degraded). | 1000 |
control | Make the node one a watcher manages: read-only at start, takes its role from /v1/control. Needs an account with the control role. | false |
groups | Table groups, each with its own primary under the watcher. 1 is one primary. More than 1 needs control. Between 1 and 64, the same on every node. | 1 |
ship-early | Send log bytes to the followers while the primary's own sync runs, so the follower's sync overlaps the primary's. The acknowledgement rule does not change (the primary is durable and sync-replicas followers confirmed). Not available for Windows logs. | false |
labels | Placement labels of this node, KEY=VALUE comma separated, for example zone=eu-1,region=eu; capacity=N weights how much data the node takes. At most 16, A-Za-z0-9._-, 512 bytes in all. See placement rules. | none |
lag-beacon-ms | How often the primary sends a caught-up marker on an idle replication stream of a group that allows follower reads, so followers can tell how stale they are. 50 to 5000. | 200 |
read-wait-ms | The longest a follower holds a read for a session position that is still arriving before it redirects to the primary. 0 never waits. | 5 |
gather-timeout-ms | One deadline for a whole query gathered from several nodes. 100 to 600000. | 5000 |
gather-max-inflight | The most gathered queries running on this node at once; more are answered 503 busy. 1 to 10000. | 64 |
gather-max-take | The most rows a gathered sorted query may fetch from each node; more is refused with 422. 1 to 1000000. | 10000 |
gather-max-groups | The most groups a gathered aggregate may have; more is refused with 422. 1 to 10000000. | 100000 |
Transport and performance#
| Setting | Meaning | Default |
|---|---|---|
udp | Also listen for UDP datagrams on the same port number. | false |
alloc-cache | Keep freed memory blocks per thread instead of returning each to the system. | true |
spin-us | The most microseconds a busy connection looks for its next request before it sleeps. 0 is never. Between 0 and 1000. | 150 |
The lsm engine#
These apply only to tables on the lsm engine. Memory use is about shards x (memtable + block cache share).
| Setting | Meaning | Default |
|---|---|---|
lsm-memtable-mb | Size of each shard's memtable before it is written out. | 64 |
lsm-block-cache-mb | Data blocks cached per shard; 0 means none. | 64 |
lsm-level1-mb | Size limit of level 1; each deeper level is 10 times bigger. | 256 |
lsm-l0-trigger | Level-0 files that start a compaction. | 4 |
lsm-l0-slowdown | Level-0 files at which writes are delayed. | 8 |
lsm-l0-stop | Level-0 files at which writes wait for compaction. | 12 |
The level-0 settings must satisfy lsm-l0-trigger <= lsm-l0-slowdown <= lsm-l0-stop.
Profiles#
A profile supplies defaults and checks, nothing else.
| Profile | Listens on | Extra |
|---|---|---|
single | loopback only | Refuses a non-loopback addr. |
primary | 0.0.0.0:7480 | Creates the read-only replicator account; keeps a replication log for lsm tables. |
replica | 0.0.0.0:7480 | Needs replica-of; refuses writes. |
The old cluster profile was removed (D51): asking for it fails with a message that points to the watcher. The settings cluster-id, cluster-peers, cluster-secret and cluster-tick-ms no longer exist in the server.
Remarks#
- Booleans accept
true,yes,on,1andfalse,no,off,0. --print-configshows the effective values and their sources and hides secrets.--check-configvalidates without writing anything, so it is safe to run on a live data directory.- A server that others follow (the
primaryprofile, a replica, a managed node or one withsync-replicas) keeps a replication log for itslsmtables, so every row is written twice there.
Examples#
A single server on a non-default port:
raftdb-server --dir ./raftdb-data --addr 127.0.0.1:7481 --shards 2Show what is in effect:
raftdb-server --print-config --shards 3A primary with one synchronous replica (the replica runs with --profile replica --replica-of PRIMARY:7480 --replica-user replicator:PASSWORD):
raftdb-server --profile primary --sync-replicas 1