Menu
#Configuration
The server is configured with environment variables and two optional arguments. There is no config file of its own. The .deb package reads /etc/ferrite/ferrite.conf into the environment through systemd, see Deployment.
#Arguments
ferrite_db [address] [sync]| Argument | Meaning |
|---|---|
| first | The address to listen on, such as 0.0.0.0:9000. Wins over FERRITE_ADDR. |
| second | The sync policy, see below. Wins over FERRITE_SYNC. |
To give the second argument you have to give the first.
#Environment variables
| Variable | Default | Meaning |
|---|---|---|
FERRITE_ADDR |
127.0.0.1:7878 |
The address to listen on |
FERRITE_DATA |
ferrite_data in the working directory |
The data directory: one <name>.log for each database, and _users.log for the users |
FERRITE_SYNC |
100 |
How the log reaches the disk, see below |
FERRITE_TOKEN |
unset | A shared secret clients must send first. At least 16 characters |
FERRITE_MAX_MEMORY |
70% of the machine's memory | A memory limit in megabytes. 0 means no limit |
FERRITE_LOG |
ferrite.log |
An old single-file log from before there were databases, moved into the data directory on the first start as the database default |
#Address
With the default loopback address, the server needs no login. To listen on anything else, you have to set FERRITE_TOKEN, or the server refuses to start:
export FERRITE_TOKEN=$(openssl rand -hex 32)
FERRITE_DATA=/var/lib/ferrite ferrite_db 0.0.0.0:7878The token is read from the environment and not from an argument, because arguments show up in ps. It is sent as plain text unless TLS is on, and the server prints a warning when a token is set on a non-loopback address without TLS. See Authentication.
#Sync policy
The sync policy sets when a write is flushed to disk. It is a number of milliseconds, or group.
| Value | Behaviour |
|---|---|
a number of milliseconds (default 100) |
The log is fsynced in the background at that interval. If the process crashes or is killed, nothing is lost, because the data is already in the operating system. A power cut can lose the last interval of writes, 100 ms by default. |
group |
A write is answered only once it is on disk, and writes from different clients share one fsync. No acknowledged write is lost, and it gets faster the more clients write at once. |
0 |
An fsync on every write. The same guarantee as group, at about 1.7 thousand writes a second however many clients there are. |
ferrite_db 127.0.0.1:7878 groupFERRITE_SYNC=group ferrite_dbSee Durability for what is and is not guaranteed.
#Memory limit
The whole database lives in RAM, so the server always has a limit unless you turn it off with 0. Unset, it is 70% of the machine's memory (or of the cgroup limit, if the server runs under one), and never under 64 MB. The server prints it at start:
memory limit 21664 MBAt the limit, inserts, updates, upserts and createIndex are refused with the limit error code, and deletes still work. On a system without /proc the limit cannot be measured, so there is none unless you set one. See Memory and limits.
#TLS and replication
These variables are described on their own pages.
| Variable | What it does | Page |
|---|---|---|
FERRITE_TLS_CERT, FERRITE_TLS_KEY |
PEM certificate and key. Both or neither. Every connection then has to use TLS 1.3 | TLS |
FERRITE_TLS_CLIENT_CA |
PEM authorities that client certificates must chain to. Needs the two above | TLS |
FERRITE_TLS_CRL |
PEM revocation lists for client certificates. Needs the two above | TLS |
FERRITE_REPLICATE_FROM |
host:port of a leader. Makes this server a read-only follower |
Replication |
FERRITE_REPLICATE_TOKEN |
The leader's token | Replication |
FERRITE_REPLICATE_USER, FERRITE_REPLICATE_PASSWORD |
Log in to the leader as a user that is admin on *, instead of the token. Set together, not with the token |
Replication |
FERRITE_REPLICATE_TLS_CA |
The authority that signed the leader's certificate | Replication |
FERRITE_REPLICATE_TLS_CERT, FERRITE_REPLICATE_TLS_KEY |
A client certificate to show the leader. Need the CA above | Replication |
A follower deletes databases and users it had of its own when it connects, so the data directory of a follower is not a place to keep anything else.
#What the server checks at start
The server exits with a message, before opening the log or binding the port, when:
- the token is shorter than 16 characters
- the address is not a loopback one and there is no token
- only one of
FERRITE_TLS_CERTandFERRITE_TLS_KEYis set, or the client CA or CRL is set without them FERRITE_SYNCis notgroupor a numberFERRITE_MAX_MEMORYis not a number of megabytes