Skip to content

Latest commit

 

History

History
130 lines (89 loc) · 6.32 KB

cockroach-init.md

File metadata and controls

130 lines (89 loc) · 6.32 KB
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 tutorial 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}}

Synopsis

Perform a one-time initialization of a cluster:

{% include_cached copy-clipboard.html %}

$ cockroach init <flags>

View help:

{% include_cached copy-clipboard.html %}

$ cockroach init --help

Flags

The cockroach init command supports the following client connection and logging flags.

{{site.data.alerts.callout_info}} cockroach init must target one of the nodes that was listed with --join when starting the cluster. Otherwise, the command will not initialize the cluster correctly. {{site.data.alerts.end}}

Client connection

{% include {{ page.version.version }}/sql/connection-parameters.md %} --cluster-name | The cluster name to use to verify the cluster's identity. If the cluster has a cluster name, you must include this flag. For more information, see cockroach start. --disable-cluster-name-verification | Disables the cluster name check for this command. This flag must be paired with --cluster-name. For more information, see cockroach start.

See Client Connection Parameters for details.

Logging

{% include {{ page.version.version }}/misc/logging-defaults.md %}

Examples

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 tutorial, see one of the Manual Deployment tutorials.

Initialize a Cluster on a Node's Machine

Secure Insecure
1. SSH to the machine where the node has been started. This must be a node that was listed with [`--join`](cockroach-start.html#networking) when starting the cluster.
  1. Make sure the client.root.crt and client.root.key files for the root user are on the machine.

  2. Run the cockroach init command with the --certs-dir flag set to the directory containing the ca.crt file and the files for the root user, and with the --host flag set to the address of the current node:

    {% include_cached 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 DB Console, and the SQL URL for clients.

1. SSH to the machine where the node has been started. This must be a node that was listed with [`--join`](cockroach-start.html#networking) when starting the cluster.
  1. Run the cockroach init command with the --host flag set to the address of the current node:

    {% include_cached 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 DB Console, and the SQL URL for clients.

Initialize a cluster from another machine

Secure Insecure
1. [Install the `cockroach` binary](install-cockroachdb.html) on a machine separate from the node.
  1. Create a certs directory and copy the CA certificate and the client certificate and key for the root user into the directory.

  2. Run the cockroach init command with the --certs-dir flag set to the directory containing the ca.crt file and the files for the root user, and with the --host flag set to the address of the node. This must be a node that was listed with --join when starting the cluster:

    {% include_cached copy-clipboard.html %}

    $ cockroach init --certs-dir=certs --host=<address of any node on --join list>

    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 DB Console, and the SQL URL for clients.

1. [Install the `cockroach` binary](install-cockroachdb.html) on a machine separate from the node.
  1. Run the cockroach init command with the --host flag set to the address of the node. This must be a node that was listed with --join when starting the cluster:

    {% include_cached copy-clipboard.html %}

    $ cockroach init --insecure --host=<address of any node on --join list>

    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 DB Console, and the SQL URL for clients.

See also