Your first cluster

Join two more nodes to the first with an enrollment token and watch the ranges spread.

A TeselaDB cluster is the same binary started on several machines. The first node creates the CA; the others join with a single-use enrollment token, get their certificate signed by that CA and start receiving range replicas.

Three nodes on your machine

To try it, teseladb dev starts several nodes in a single process. Node k listens on the client port plus k:

Shell
teseladb dev --nodes 3

Three nodes on three machines

1. Start the first node

On node-01, listen on an address the other machines can reach:

Shell
teseladb start --dbpath /var/lib/teseladb \
  --bind_ip 0.0.0.0 --peer-listen 0.0.0.0:27100 --admin-listen 0.0.0.0:27200

2. Create an enrollment token

On node-01. The token is single-use and expires; --ttl sets how long it lasts. teseladb admin presents itself to the node with the certificate it finds in --dbpath:

Shell
teseladb admin --dbpath /var/lib/teseladb token create --ttl 1h

3. Join the other nodes

On node-02 and node-03, each with its own token:

Shell
teseladb start --dbpath /var/lib/teseladb \
  --bind_ip 0.0.0.0 --peer-listen 0.0.0.0:27100 --admin-listen 0.0.0.0:27200 \
  --join node-01:27100 --enroll-token <token>

The new node checks the CA fingerprint the token carries, receives its certificate and the master key over that encrypted channel and joins the cluster. A used or expired token is rejected.

Look at the cluster

Shell
teseladb admin --dbpath /var/lib/teseladb nodes
teseladb admin --dbpath /var/lib/teseladb ranges --collection shop.orders

nodes lists the nodes and their state. ranges shows the ranges of a collection, their replicas and their leader. As the collection grows, its ranges split and the balancer spreads replicas and leaders across the three nodes.

Next step

Before taking it to production, go through the Production checklist.