Command line / Nodes
Nodes
A store becomes a node when serve is given --node-listen, --from or
--node-config: it keeps a log of each file it writes, serves those files to
other nodes, and copies the files of the node it takes from. Every file has
one home that writes it; copies read locally and pass their writes home. The
commands here start nodes, show how they stand, and move a home when one is
gone.
# the home
tinystore serve ./us --node-listen 0.0.0.0:7444 --node-config node.toml
# a copy of every file of the home
tinystore serve ./eu --from us.internal:7444 --node-listen 0.0.0.0:7444 --node-config node.tomltoken-file = "/etc/tinystore/node-token" # the token nodes show each other
advertise = "eu.internal:7444" # where other nodes reach this one
[tls]
cert = "/etc/tinystore/node.pem"
key = "/etc/tinystore/node.key"
roots = "/etc/tinystore/ca.pem"| Flag | Does |
|---|---|
--node-listen <host:port> | where other nodes copy from this one |
--from <host:port> | a node it copies from; again for the next to try |
--node-config <file.toml> | the rest of what the node is |
The config's other keys are files, catalog, synchronous,
synchronous-with, failover and insecure, beside token-file and
advertise above and [tls]'s cert, key and roots: the certificate a
node shows, its key, and the certificates it trusts. A link beyond its own
machine takes TLS unless insecure = true.
files names the files a node copies, as ["kv.db", "sql/app.db"]; without
it a copy takes every file of its home. records.db, metrics.db and the
databases of local/ are never copied: each node keeps its own, and a
files that names one is refused at the start
(why).
node status
tinystore node status ./eu
tinystore node status ./eu --jsonIt shows the node's files, which it writes and which it copies, its links, and how far behind its home each copy is. It reads beside the running node.
promote and demote
When a home is gone and will not come back soon, a person promotes a copy:
# stop the copy's server first
tinystore node promote ./eu --from us.internal:7444
tinystore serve ./eu --node-listen 0.0.0.0:7444 --node-config node.toml # without --from: it is the home now| Command | Does |
|---|---|
node promote <dir> [file] | makes a stopped node's copies its own, at the next epoch |
node demote <dir> [file] | makes an old home's files copies again, before it serves |
- The node must be stopped.
promoteasks each node named by--fromfirst. One that still serves the file would make a second home, so the promotion is refused unless--force.- Commits the old home had not shipped are lost with it, unless the home was
synchronous.
demotedrops, counts and logs the ones the old home still holds, and follows the new home before it opens a writer.
tinystore node demote ./us
tinystore serve ./us --from eu.internal:7444 --node-listen 0.0.0.0:7444 --node-config node.tomlwitness
A draft: a witness keeps each file's lease and no data, and gives the lease to
the freshest copy when a home goes quiet: the copy with the latest epoch, then
the one with the most entries. A copy that came back further on in an older
epoch holds commits of an older home, not the last one's. A home writes only
while it holds its lease: a write, or a transaction that would commit after
the lease ran out, fails unavailable and commits nothing. Nodes name the
witness as failover in their config.
tinystore witness ./witness --listen 0.0.0.0:7445 --token-file token| Flag | Does |
|---|---|
--listen <host:port> | where nodes reach it |
--token-file <file> | the token nodes say to it |
--tls-cert, --tls-key | its certificate and key |
--insecure | plain TCP beyond this machine |
See also
- The command line.
- Readers in another region and When a home dies in the Handbook.