Install CockroachDB cluster on Rocky Linux

This article will walk you through the process of how to install CockroachDB cluster on Rocky Linux. CockroachDB is an open-source distributed and scalable SQL database that was created specifically for cloud-native applications and development.

CockroachDB features database replication with strong consistency, SQL query language support, fault tolerance, automated scaling and repairing, and high availability.

CockroachDB can be deployed as a dedicated, serverless or self-hosted database. This tutorial features installing CockroachDB cluster on Rocky Linux using self-hosted deployment option with two servers/nodes.

Install CockroachDB cluster on Rocky Linux


  • Two or more Rocky Linux servers
  • Root privileges on both servers

The IP addresses for the servers/nodes are:

  • Server 1 IP:
  • Server 2 IP:

Connection through firewall

Allow connection through ports 8080 and 26257 on both your servers. Rocky Linux has firewall running by default.

So open ports 8080 and 26257:

sudo firewall-cmd --permanent --add-port={8080,26257}/tcp

Reload the firewall

sudo firewall-cmd –-reload

Configure SELinux policy

Set permissive mode temporarily for now

sudo setenforce 0

To disable SELinux enforcing mode permanently upon reboot, run the commands below:

sudo sed -i 's/enforcing/permissive/g' /etc/selinux/config

Install CockroachDB cluster on Rocky Linux

Download the binary file on server 1. Extract and copy the files to your system’s path

curl | \
tar -xz && sudo cp -i cockroach-v22.1.0.linux-amd64/cockroach /usr/local/bin/

Create a directory to store library files that provide spatial features.

mkdir -p /usr/local/lib/cockroach

Copy the library files to the directory:

sudo cp -i cockroach-v22.1.0.linux-amd64/lib/ /usr/local/lib/cockroach/
cp -i cockroach-v22.1.0.linux-amd64/lib/ /usr/local/lib/cockroach/

CockroachDB is now installed on the first server. Confirm installation by checking the version:

$ cockroach version
Build Tag:        v22.1.
Build Time:       2022/0/22 1:7:47
Distribution:     CCL
Platform:         linux amd64 (x86_64-pc-linux-gnu)
Go Version:       go1.17.11
C Compiler:       gcc 6.5.0
Build Commit ID:  fc456a26830067b6dfbb8cd87e093a28d9b833d1
Build Type:       release

Move to the second server and install CockroachDB by repeating the process.

Create clusters

First, create the first cluster on the first server by entering the --store, --listen-addr and --http-addr.

cockroach start --insecure --store=server1 \
--listen-addr= \
--http-addr= \
--join=, --background

Meaning of the above flags:

  • –store is the cluster for storing the data
  • –listen-addr is the IP address for running on the server using port 25267.
  • –http-addr is the IP address the Cockroachdb web-based administration will be accessed via port 8080.
  • –insecure is for using unsecure(http) connection

Create the second cluster on the second server with the IP address(

cockroach start --insecure --store=server2 \
--listen-addr= --http-addr= \
--join=, --background

Then join the clusters into one cluster using the first server.

cockroach init --insecure --host=
Cluster successfully initialized

Access the web interface

Enter URL http://SERVER:8080 in your browser (SERVER is the IP address of server1), for instance,

The web-base management console loads:

Install CockroachDB cluster on Rocky Linux
CockroachDB web console

Testing the clusters

Write simple SQL statements check if data can be duplicated to all the servers.

Connect to server 1 cluster shell using the command:

cockroach sql --insecure --host=

Create a database i.e. itnixpro


Next create a table users under the above database

CREATE TABLE itnixpro.users (id INT PRIMARY KEY, name TEXT); 

Now insert some data to the table:

INSERT INTO itnixpro.users (id, name) values (1,'Barasa');

Display the data:

select * from itnixpro.users;                   
  id | name
   1 | Barasa
(1 row)

Time: 3ms total (execution 2ms / network 1ms)

Check if the data was replicated to the second server. Connect to the second cluster shell:

cockroach sql --insecure --host=

Display the data on the second cluster. The data has been duplicated to the second cluster successfully.

select * from itnixpro.users;                   
  id | name
   1 | Barasa
(1 row)

Time: 101ms total (execution 101ms / network 0ms)


You have successfully managed to install CockroachDB Cluster on Rocky Linux. Remember to secure your database in a production environment by using SSL certificates.

More information is found on CockroachDB documentation

Similar interesting tutorials

Install CockroachDB on Ubuntu 22.04

Install CockroachDB on Debian 11

Install phpMyAdmin with Apache on Rocky Linux

Install CockroachDB on Rocky Linux

Android Developer | Linux | Technical Writer | Backend Developer

Leave a Comment