Getting started

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@shop

Options#

General#

SettingMeaningDefault
profilesingle, primary or replica (see below). Only on the command line, in the environment as RAFTDB_PROFILE, or in the file.single
dirData directory./var/lib/raftdb or %ProgramData%\RaftDB if that folder exists, otherwise ./raftdb-data
addrHOST: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
shardsNumber of shard threads per table. Every table of a server uses the same number.The number of cores, at most 4
enginememory (all data in RAM) or lsm (data may exceed RAM). Applies to tables created afterwards; existing tables keep their engine.memory
checkpoint-min-mbAt 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
secondsStop gracefully after this many seconds (tests and demos).run until stopped
studioFolder of the Studio's static files; they are then served at /.none

Accounts and access#

SettingMeaningDefault
userNAME: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
tokenA shared secret every client must send. Holders of the token are administrators everywhere.none
openServe with no login at all, and create no admin account. For a machine you fully trust.false
corsAn origin whose pages may call the API, repeatable. Never a substitute for authentication; * must not be used on an open server.none
control-peersHOST: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-addrHOST:PORT of an extra HTTPS listener for the HTTP API (the main port stays plain).none
https-cert, https-keyPEM certificate chain and private key for https-addr; without them a self-signed certificate is made at each start.none
allow-remote-serversLet 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#

SettingMeaningDefault
replica-ofHOST:PORT of the primary to copy. Required by the replica profile. Cannot be combined with control.none
replica-userNAME:PASSWORD the node uses to read its primary (and, on a managed node, the leader).none
replica-tokenA token for the primary, as an alternative.none
sync-replicasHow many replicas must confirm a write before it is acknowledged. 0 is asynchronous.0
sync-timeout-msHow long a write waits for them before it is acknowledged anyway (and counted as degraded).1000
controlMake the node one a watcher manages: read-only at start, takes its role from /v1/control. Needs an account with the control role.false
groupsTable 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-earlySend 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
labelsPlacement 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-msHow 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-msThe 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-msOne deadline for a whole query gathered from several nodes. 100 to 600000.5000
gather-max-inflightThe most gathered queries running on this node at once; more are answered 503 busy. 1 to 10000.64
gather-max-takeThe most rows a gathered sorted query may fetch from each node; more is refused with 422. 1 to 1000000.10000
gather-max-groupsThe most groups a gathered aggregate may have; more is refused with 422. 1 to 10000000.100000

Transport and performance#

SettingMeaningDefault
udpAlso listen for UDP datagrams on the same port number.false
alloc-cacheKeep freed memory blocks per thread instead of returning each to the system.true
spin-usThe 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).

SettingMeaningDefault
lsm-memtable-mbSize of each shard's memtable before it is written out.64
lsm-block-cache-mbData blocks cached per shard; 0 means none.64
lsm-level1-mbSize limit of level 1; each deeper level is 10 times bigger.256
lsm-l0-triggerLevel-0 files that start a compaction.4
lsm-l0-slowdownLevel-0 files at which writes are delayed.8
lsm-l0-stopLevel-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.

ProfileListens onExtra
singleloopback onlyRefuses a non-loopback addr.
primary0.0.0.0:7480Creates the read-only replicator account; keeps a replication log for lsm tables.
replica0.0.0.0:7480Needs 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, 1 and false, no, off, 0.
  • --print-config shows the effective values and their sources and hides secrets.
  • --check-config validates without writing anything, so it is safe to run on a live data directory.
  • A server that others follow (the primary profile, a replica, a managed node or one with sync-replicas) keeps a replication log for its lsm tables, 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 2

Show what is in effect:

raftdb-server --print-config --shards 3

A 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

See also#