How to Install CockroachDB Cluster on Ubuntu 24.04

 

 

CockroachDB is a powerful, open-source distributed SQL database designed for cloud applications. Installing a CockroachDB cluster on Ubuntu 24.04 can enhance your application's scalability and resilience. This guide will walk you through the installation process on your VPS server. For reliable hosting solutions, consider using windowsvps for your next VPS server deployment.

Prerequisites

Before you begin, ensure that you have the following:

  • A VPS server running Ubuntu 24.04.
  • Root or sudo access to the server.
  • At least 2 GB of RAM and 2 CPU cores for each node.

Step 1: Update Your System

Start by updating your package list and installed packages:

sudo apt update && sudo apt upgrade -y

Step 2: Install CockroachDB

Download the latest stable version of CockroachDB:

wget https://binaries.cockroachdb.com/cockroach-v22.1.6.linux-amd64.tgz

Extract the downloaded archive:

tar -xzvf cockroach-v22.1.6.linux-amd64.tgz

Move the Cockroach binary to the appropriate location:

sudo cp cockroach-v22.1.6.linux-amd64/cockroach /usr/local/bin/

Make the Cockroach binary executable:

sudo chmod +x /usr/local/bin/cockroach

Step 3: Start the CockroachDB Cluster

To start a single-node CockroachDB cluster, run:

cockroach start --insecure --listen-addr=localhost:26257 --http-port=8080 --store=store=path/to/store

Make sure to replace path/to/store with a directory where you want to store the data.

Step 4: Initialize the Database

In a new terminal window, initialize the database by running:

cockroach init --insecure --host=localhost:26257

Step 5: Access the CockroachDB Admin UI

You can access the CockroachDB Admin UI by navigating to http://localhost:8080 in your web browser.

Step 6: Joining Additional Nodes (Optional)

If you want to add more nodes to your cluster, run the following command on each additional node:

cockroach start --insecure --join=localhost:26257 --listen-addr=:26257 --http-port=8080 --store=path/to/store

Replace <node_ip> with the actual IP address of the node you are adding.

Step 7: Configure CockroachDB as a Service (Optional)

To run CockroachDB as a service, create a systemd service file:

sudo nano /etc/systemd/system/cockroach.service

Add the following configuration:

[Unit]
Description=CockroachDB
After=network.target

[Service]
User=root
ExecStart=/usr/local/bin/cockroach s
  • 0 istifadəçi bunu faydalı hesab edir
Bu cavab sizə kömək etdi?

Uyğun məqalələr

Boost Your Ubuntu System's Performance with a Swap File: A Step-by-Step Guide

What is a Swap File? A swap file in Ubuntu serves as dedicated virtual memory on your hard...

How to Migrate ISPConfig 2, ISPConfig 3.x, Confixx, CPanel or Plesk to ISPConfig 3.2 (single server)

Introduction Migration from other control panels like ISPConfig 2, ISPConfig 3.x, Confixx,...

How to Install and Configure Zabbix Server and Client on Rocky Linux 9

Introduction Zabbix is an open-source monitoring solution that provides real-time...

How to Install CockroachDB Cluster on Debian 12

Introduction CockroachDB is a distributed SQL database built to handle large-scale,...

How to Install Joomla with Apache and Let's Encrypt SSL on AlmaLinux 9

Introduction Joomla is a popular open-source content management system (CMS) used to build...