Clickhouse Installation on Ubuntu/Linux Box

Prerequisites

  • One Ubuntu server with a sudo enabled non-root user and firewall setup. The server should have at least 2GB of RAM.
  • (Optional) A secondary Ubuntu 20.04 server with a sudo enabled non-root user and firewall setup.

Step 1 — Installing ClickHouse

In this section, you will install the ClickHouse server and client programs using apt.

  1. Yandex maintains an APT repository that has the latest version of ClickHouse. Add the repository’s GPG key so that you’ll be able to securely download validated ClickHouse packages:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E0C56BD4

You will see output similar to the following:

Output
Executing: /tmp/apt-key-gpghome.zJVSvL3NNE/gpg.1.sh --keyserver keyserver.ubuntu.com --recv E0C56BD4
gpg: key C8F1E19FE0C56BD4: public key "ClickHouse Repository Key <milovidov@yandex-team.ru>" imported
gpg: Total number processed: 1
gpg:               imported: 1

The output confirms it has successfully verified and added the key.

2)Add the repository to your APT repositories list by executing:

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

Here you’ve piped the output of echo to sudo tee so that this output can print to a root-owned file.

3)Now, update your packages:

sudo apt update

4)The clickhouse-server and clickhouse-client packages will now be available for installation. Install them with:

sudo apt install clickhouse-server clickhouse-client

During the installation, you will be asked to set a password for the default ClickHouse user.

You’ve installed the ClickHouse server and client successfully. You’re now ready to start the database service and ensure that it’s running correctly.

Step 2 — Starting the Service

The clickhouse-server package that you installed in the previous section creates a systemd service, which performs actions such as starting, stopping, and restarting the database server. systemd is an init system for Linux to initialise and manage services. In this section you’ll start the service and verify that it is running successfully.

1)Start the clickhouse-server service by running:

sudo service clickhouse-server start

2)The previous command will not display any output. To verify that the service is running successfully, execute:

sudo service clickhouse-server status

You’ll see output similar to the following:

Output
● clickhouse-server.service - ClickHouse Server (analytic DBMS for big data)
     Loaded: loaded (/etc/systemd/system/clickhouse-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-06-14 09:44:08 IST; 4h 42min ago
   Main PID: 1605 (clckhouse-watch)
      Tasks: 213 (limit: 18810)
     Memory: 2.1G
        CPU: 9min 32.908s
     CGroup: /system.slice/clickhouse-server.service
             ├─1605 clickhouse-watchdog "" "" "" "" "" "" "" --config=/etc/clickhouse-server/config.xml --pid-file=/run/clickhouse-server/clickhouse-server.pid
             └─1617 /usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml --pid-file=/run/clickhouse-server/clickhouse-server.pid

The output notes that the server is running.