title | summary | toc | key |
---|---|---|---|
cockroach init |
Perform a one-time-only initialization of a CockroachDB cluster. |
true |
initialize-a-cluster.html |
This page explains the cockroach init
command, which you use to perform a one-time initialization of a new multi-node cluster. For a full walk-through of the cluster startup and initialization process, see one of the Manual Deployment tutorials.
{{site.data.alerts.callout_info}}
When starting a single-node cluster with cockroach start-single-node
, you do not need to use the cockroach init
command.
{{site.data.alerts.end}}
Perform a one-time initialization of a cluster:
{% include copy-clipboard.html %}
$ cockroach init <flags>
View help:
{% include copy-clipboard.html %}
$ cockroach init --help
The cockroach init
command supports the following client connection and logging flags.
{% include {{ page.version.version }}/sql/connection-parameters.md %}
See Client Connection Parameters for details.
By default, the init
command logs errors to stderr
.
If you need to troubleshoot this command's behavior, you can change its logging behavior.
Usage of cockroach init
assumes that nodes have already been started with cockroach start
and are waiting to be initialized as a new cluster. For a more detailed walk-through, see one of the Manual Deployment tutorials.
-
Make sure the
client.root.crt
andclient.root.key
files for theroot
user are on the machine. -
Run the
cockroach init
command with the--certs-dir
flag set to the directory containing theca.crt
file and the files for theroot
user, and with the--host
flag set to the address of the current node:{% include copy-clipboard.html %}
$ cockroach init --certs-dir=certs --host=<address of this node>
At this point, all the nodes complete startup and print helpful details to the standard output, such as the CockroachDB version, the URL for the Admin UI, and the SQL URL for clients.
-
Run the
cockroach init
command with the--host
flag set to the address of the current node:{% include copy-clipboard.html %}
$ cockroach init --insecure --host=<address of this node>
At this point, all the nodes complete startup and print helpful details to the standard output, such as the CockroachDB version, the URL for the Admin UI, and the SQL URL for clients.
-
Create a
certs
directory and copy the CA certificate and the client certificate and key for theroot
user into the directory. -
Run the
cockroach init
command with the--certs-dir
flag set to the directory containing theca.crt
file and the files for theroot
user, and with the--host
flag set to the address of any node:{% include copy-clipboard.html %}
$ cockroach init --certs-dir=certs --host=<address of any node>
At this point, all the nodes complete startup and print helpful details to the standard output, such as the CockroachDB version, the URL for the Admin UI, and the SQL URL for clients.
-
Run the
cockroach init
command with the--host
flag set to the address of any node:{% include copy-clipboard.html %}
$ cockroach init --insecure --host=<address of any node>
At this point, all the nodes complete startup and print helpful details to the standard output, such as the CockroachDB version, the URL for the Admin UI, and the SQL URL for clients.