Right way to start a cockroachdb cluster?

I am starting my cockroachdb cluster by specifying two join flags as opposed to specifying only one join flag as mentioned in the github readme.

here is how I start my cluster:

cockroach start --store=/data0
cockroach start --store=/data1 --port=26258 --http-port=8081 --join=localhost:26257 --join=localhost:26259 &
cockroach start --store=/data2 --port=26259 --http-port=8082 --join=localhost:26257 --join=localhost:26258 &

The reason why I start with two join flags is that even if the first node fails to start, the second and third nodes can still join with each other as they form a majority.
This seems to be working well but I wanted to confirm if this is right and supported? and if yes, probably can mention in the readme.

Starting the cluster that way is fine. You can also specify both addresses as a comma-separated list in the same join flag. eg: cockroach start --store=/data1 --port=26258 --http-port=8081 --join=localhost:26257,localhost:26259

A few other things to note:

  • you can use --background instead of &
  • once a node has talked to an existing node once, it will remember and not need the --join flag.

The second point means that if you start the nodes as you mentioned, you can wait until they connect to each other (ie: the admin UI shows three nodes in the system), then take them all down, and start them all up without any --join flags whatsoever, and they will still be fine.
However, it’s also fine to leave the --join flags as they are.

And you are correct, we should mention the ability to specify multiple hosts in the --join flag as part of our docs.

1 Like