There is not a direct way to query for initialization status. You can try to connect to a node and perform a query (such as
SELECT 1), and if it succeeds, the cluster is initialized. If not, it’s ambiguous: you might be connecting to a newly-provisioned node that hasn’t connected to the initialized parts of the cluster yet.
init too many times could create multiple clusters (each node would pick one of the clusters to join and would be unable to talk to nodes that joined another cluster), so we do not recommend retrying the
init command. If
cockroach init fails, tear down everything you’ve done (specifically, stop all the cockroach processes and delete their store directories) and start over from scratch instead of trying to re-run
init on the same nodes and stores.
One thing we’ve considered to make this easier in future releases is to make the
init command take the number of expected nodes as an argument. Then it could (safely) fail if run against a node with fewer than the expected number of peer connections.