What does "cockroach init" actually do?

Since version 1.1, there is a new command init. But init is not mentioned in Start a Local Cluster (Secure).

Does init need to be executed before the first use of a CockroachDB cluster? Before version 1.1, I can use the cluster after starting all the nodes with start commands.

And what does “cockroach init” actually do?

Hi @yaojingguo,

I asked about the lack of init in the “Start a local cluster” pages, and apparently you can start a single-node cluster by excluding the --join flag. In that case, init isn’t required. (This is how it is done on those pages.)

Does init need to be executed before the first use of a CockroachDB cluster?

Only if you provided --join flags to all of the nodes in the cluster, according to this forum answer (which also has a link to the init docs) Problem starting a cluster: Gossip error

what does “cockroach init” actually do?

I will leave this for an engineer to answer, since I’m not sure about the details (other than what’s written in the docs at https://www.cockroachlabs.com/docs/stable/initialize-a-cluster.html, which state: “perform a one-time initialization” of the cluster).

Oh - a little more searching turned up the RFC for init, which has more details that may answer your question:

Filed an issue on the docs repo to add more detail: https://github.com/cockroachdb/docs/issues/2756

@rmloveland Thanks for your reply. I am clear now.

1 Like