How to Install ClickHouse on Ubuntu 20.04

August 15, 2020

Introduction

ClickHouse is a column-oriented database designed to address OLAP – Online Analytical Processing. OLAP is a technique for advanced big data analysis.

The language ClickHouse uses is a variation of SQL, which helps beginners learn this query language faster.

This tutorial will show you how to install and start using ClickHouse on Ubuntu 20.04.

tuorial on installing ClickHouse on Ubuntu 20.04

Prerequisites

  • A system running Ubuntu 20.04
  • A user account with sudo or root privileges
  • Access to a terminal window / command-line prompt

Installing ClickHouse on Ubuntu 20.04

To learn how to install ClickHouse on Ubuntu, follow the steps below. Make sure not to skip any steps to avoid potential issues when launching the tool.

STEP 1: Install apt-transport Package

ClickHouse needs the apt-transport package that does not come by default with Ubuntu 20.04.

To install the tool, open a terminal window, and update the package repository:

sudo apt update

Then, install the apt-transport-https package with the following command:

sudo apt install apt-transport-https ca-certificates dirmngr/code>
screenshot of the progress when installing apt-transport-https package

STEP 2: Add the Repository GPG Key

Before you download and install the latest ClickHouse version, add the GPG key from the Yandex repository:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E0C56BD4

The terminal output shows a confirmation message when the key is added.

Confirmation of successful repository key addition

Make sure the output shows the key is processed and imported.

STEP 3: Add ClickHouse to APT Repository

Now, add ClickHouse to your software repository.

Execute the following echo command to add the repository to the clickhouse.list file:

echo "deb http://repo.yandex.ru/clickhouse/deb/stable/ main/" | sudo tee /etc/apt/sources.list.d/clickhouse.list

The output returns a new line. Update the package repository one more time:

sudo apt update

When the system finishes, move to the final step.

STEP 4: Install ClickHouse Server and Client

Install the ClickHouse client and server:

sudo apt install clickhouse-server clickhouse-client

Enter a password when prompted.

Popup to enter a password for ClickHouse default user

This is the password for the default user that you will later use to load the ClickHouse console.

The final output after the installation looks similar to the one in the image below:

Terminal output when installing clickhouse-server and clickhouse-client

Getting Started With ClickHouse

Now that the ClickHouse server and client is installed on Ubuntu, Linux systemd controls this service. You can start, stop, and check the ClickHouse service with a few commands.

To start the clickhouse-server, use:

sudo systemctl start clickhouse-server

The output does not return a confirmation.

To check the ClickHouse service status, enter:

sudo systemctl status clickhouse-server
Checking the status of the ClickHouse service on Ubuntu

To stop the ClickHouse server, run this command:

sudo systemctl stop clickhouse-server

To enable ClickHouse on boot:

sudo systemctl enable clickhouse-server

Start ClickHouse Session

To start working with ClickHouse databases, launch the ClickHouse client. When you start a session, the procedure is similar to other SQL management systems.

To start the client, use the command:

clickhouse-client

You may get this error:

Code: 516. DB::Exception: Received from localhost:9000. DB::Exception: default: Authentication failed: password is incorrect or there is no user with such name.

screenshot of Clickhouse code 516 error

When that error occurs, you need to define the password entered during the installation for the default user.

To do so, enter:

clickhouse-client --password test1234 --user default

Replace the sample password with your own.

The session starts.

ClickHouse client session started in the terminal.

Conclusion

The steps in this guide showed you how to install ClickHouse on Ubuntu 20.04 and get started.

If you get an error with code 516 when you start the ClickHouse client, use the solution we provided in the final section.

If you are using CentOS, be sure to read our guide on ClickHouse installation on CentOS 7.

Was this article helpful?
YesNo
Goran Jevtic
Goran combines his leadership skills and passion for research, writing, and technology as a Technical Writing Team Lead at phoenixNAP. Working with multiple departments and on various projects, he has developed an extraordinary understanding of cloud and virtualization technology trends and best practices.
Next you should read
What Is NoSQL Database? NoSQL Explained
June 17, 2020

The article provides a detailed explanation of what a NoSQL databases is and how it differs from relational...
Read more
NoSQL Database Types
June 10, 2020

NoSQL databases are an alternative to the traditional SQL databases. They are more flexible, scalable and...
Read more
How to Install and Configure MySQL on a Windows Server
April 23, 2020

The article provides many images that guide you through each individual step of a MySQL installation on...
Read more
How to Install ClickHouse on CentOS 7
August 23, 2019

ClickHouse is an open-source column-oriented database management system. It is a fast, scalable, and...
Read more