UbuntuUbuntu Based

How To Install CockroachDB on Ubuntu 22.04 LTS

Install CockroachDB on Ubuntu 22.04

In this tutorial, we will show you how to install CockroachDB on Ubuntu 22.04 LTS. CockroachDB is favored for its resilience, as it provides strong consistency and can survive hardware or network failures. It’s particularly well-suited for applications that demand high availability and low-latency access to data.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of CockroachDB on Ubuntu 22.04. You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.

Prerequisites

  • A server running one of the following operating systems: Ubuntu 22.04, 20.04, and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for CockroachDB.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install CockroachDB on Ubuntu 22.04 LTS Jammy Jellyfish

Step 1. First, make sure that all your system packages are up-to-date by running the following apt commands in the terminal.

sudo apt update
sudo apt upgrade

Step 2. Install Required Dependencies.

CockroachDB has certain dependencies that need to be installed. Use the following command to install them:

sudo apt install -y curl lsof wget

Step 3. Installing CockroachDB on Ubuntu 22.04.

Now, let’s proceed with downloading the latest version of CockroachDB:

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

After downloading, it’s time to extract the files from the downloaded archive. Use the following command:

tar -xvzf cockroach-latest.linux-amd64.tgz

CockroachDB is a single binary executable. To make it accessible system-wide, move it to a directory listed in your system’s PATH:

sudo mv cockroach /usr/local/bin/

Now, it’s crucial to create a data directory where CockroachDB will store its data:

mkdir -p ~/cockroach-data

Initialize a new CockroachDB node using the following command:

cockroach init --insecure --host=localhost

The ‘--insecure‘ flag allows for quick setup without encryption. In production environments, you should use secure configurations.

Step 4. Configuring CockroachDB.

CockroachDB needs configuration before it can be used effectively. You must specify the IP address and port CockroachDB should listen on. Edit the cluster settings in the ‘cockroach’ binary:

cockroach start --background --store=path-to-your-data-directory \
--listen-addr=<your-ip-address> --http-addr=<your-ip-address>:8080

Replace <your-ip-address> with your system’s IP address.

Assign a unique cluster name to your CockroachDB instance. For example:

--join=<your-ip-address>:26257 --locality=region=us,zone=us-west

To start CockroachDB, use the following command:

cockroach start --background --store=path-to-your-data-directory \
--listen-addr=<your-ip-address> --http-addr=<your-ip-address>:8080

Step 5. Access the CockroachDB Admin UI.

To access the CockroachDB Admin UI, open your web browser and navigate to:

http://<your-ip-address>:8080

Install CockroachDB on Ubuntu 22.04 LTS Jammy Jellyfish

Congratulations! You have successfully installed CockroachDB. Thanks for using this tutorial for installing CockroachDB on the Ubuntu system. For additional help or useful information, we recommend you check the official CockroachDB website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button