CockroachDB is a distributed SQL database built to handle large-scale, high-availability workloads. Installing CockroachDB as a cluster on Debian 12 allows you to harness its scalability and fault tolerance for your applications. In this guide, we'll walk you through the step-by-step process of setting up a CockroachDB cluster on Debian 12.


Before you begin, make sure you have the following:

  • Multiple Debian 12 servers for setting up the cluster
  • Root access to each server
  • A stable network connection between the servers

Step 1: Install CockroachDB on Debian 12 Servers

First, SSH into each Debian 12 server and download the CockroachDB binary:

wget -qO- | tar  xvz

Move the extracted binary to a directory in your system's PATH:

sudo mv cockroach-v22.1.0.linux-amd64/cockroach /usr/local/bin/

Step 2: Configure CockroachDB Nodes

On each server, create a directory to store CockroachDB data:

sudo mkdir -p /var/lib/cockroach

Initialize the first node as the cluster leader:

cockroach init --certs-dir=/var/lib/cockroach/certs --host=your_first_node_ip

Step 3: Start CockroachDB Nodes

On each server, start the CockroachDB node:

cockroach start --certs-dir=/var/lib/cockroach/certs --advertise-host=your_node_ip

Step 4: Join Nodes to the Cluster

On each server, join the node to the cluster:

cockroach start --certs-dir=/var/lib/cockroach/certs --advertise-host=your_node_ip --join=your_first_node_ip:26257

Step 5: Access CockroachDB Web Interface

Access the CockroachDB web interface using any node's IP address:


Step 6: Verify Cluster Status

Check the status of the CockroachDB cluster using the built-in SQL client:

cockroach sql --certs-dir=/var/lib/cockroach/certs --host=your_first_node_ip:26257 --execute="SHOW CLUSTER STATUS"


Congratulations! You've successfully installed and configured a CockroachDB cluster on Debian 12. You can now leverage CockroachDB's distributed architecture for your high-availability database workloads.

Was this answer helpful? 0 Users Found This Useful (0 Votes)