ThingsDB can work with a single node but is designed to work with at least two nodes but three nodes are preferred. Running on three nodes brings redundancy and ensures the database stays operational, even while you for example upgrade ThingsDB to a newer version.
After building the source code and making a symlink, you can start your first node using the following command. You need to add the
--init flag to initialize a new ThingsDB store.
Starting a second (or other) node needs a secret.
thingsdb --secret second
The secret is used when adding this node; see new_node documentation on how to add a second (or other) node to ThingsDB.
|Show the help message and exit.
|Define which ThingsDB configuration file to use.
--secret based on the
THINGSDB_NODE_SECRET environment variable. A use case is explained in the next paragraph.
|Initialize a new ThingsDB store.
--secret to remove existing data if exists.
|Set one time secret and wait for request to join.
|Rebuild the node (can only be used when having >1 nodes). A use case is explained in the next paragraph.
|Forget all nodes info and load ThingsDB with a single node. A use case is explained in the next paragraph.
|Show version information and exit.
|Set initial log level: debug, info, warning, error, critical.
|Use colorized logging.
|Confirm questions with yes.
In containerized environments like kubernetes it is often useful to initialize automatically based on the node name.
--deploy argument is created for this purpose and triggers the following behavior.
-0, the node is considered to be the first node and will automatically set
--init argument in case the node is started for the first time.
-0, then the node will be started with
--secret when the node is started
for the first time. The secret will be equal to the node name unless the environment
THINGSDB_NODE_SECRET is set.
When you need to restore from a back up you will need to set the environment variable
THINGSDB_STORAGE_PATH to the latest backup file (.tar.gz). Then you can start ThingsDB again with the following command:
--forget-nodes flag is in this case very useful. The flag causes to forget all nodes. You can just start with one node without getting in a situation where the quorum will not be reached when multiple nodes are down. After the first node has started you can then simply add other nodes again.
When you get in the situation that one of your nodes is corrupted for some reason, you can shutdown the node and start it again with the following flag:
This causes the node to wipe its corrupted data and synchronize again with one of the other healthy nodes.
--rebuild flag is a simplified way of doing the following but same thing. You shutdown the corrupted node. Delete it as well, so the other nodes forget about this node. Then start the node again with the following command:
--force flag causes to wipe all the stored data and start fresh. Then you can add this node again to the ThingsDB store.
As you will notice this takes a couple of more steps, so it is easier to just use the