How to Install ClickHouse on Ubuntu 22.04

ClickHouse is a modern, fast and open source database management system used for online analytical processing (OLAP).

It is column-oriented and stores records in blocks grouped by columns instead of rows. It allows you to generate analysis reports using SQL queries in real time. In addition, columnar databases take less time to read data during query completion than traditional row-based systems. It can be used in a system with a small amount of RAM, even with 2GB of RAM, but it requires additional tuning and can enter at low speeds.

This tutorial will show you how to install ClickHoof on Ubuntu 22.04.

Prerequisites

  1. A server running Ubuntu 22.04.
  2. The root password is configured on your server.

Install required dependencies

Before you begin, you should update and upgrade all system packages to an up-to-date version. You can update them by running the following command:

apt update -y apt upgrade -y

After upgrading all packages, run the following command to install other required packages:

apt-get install curl gnupg2 wget git apt-transport-https ca-certificates -y

Once all the necessary packages are installed, you can proceed to the next step.

ClickHouse Settings

By default, the ClickHouse package is not included in the default Ubuntu 22.04 repositories. So you will need to add the ClickHouse repository to your system.

First, download and add the GPG key with the following command:

gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv 8919F6BD2B48D754 gpg --export --armor 8919F6BD2B48D754 | gpg --dearmour -o /etc/apt/trusted.gpg.d/clickhouse-key.gpg

 

Next, add the ClickHouse repository to APT with the following command:

echo "deb [arch=amd64] https://packages.clickhouse.com/deb stable main" | tee /etc/apt/sources.list.d/clickhouse.list

Next, update the repository and install the ClickHouse server and client packages with the following command:

apt-get update -y apt-get install clickhouse-server clickhouse-client -y

During the installation process, you will be asked to provide a password for the ClickHouse admin user as shown below:

Enter password for default user: Password for default user is saved in file /etc/clickhouse-server/users.d/default-password.xml. Setting capabilities for clickhouse binary. This is optional. chown -R clickhouse:clickhouse '/etc/clickhouse-server' ClickHouse has been successfully installed. Start clickhouse-server with: sudo clickhouse start Start clickhouse-client with: clickhouse-client --password Synchronizing state of clickhouse-server.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable clickhouse-server Created symlink /etc/systemd/system/multi-user.target.wants/clickhouse-server.service → /lib/systemd/system/clickhouse-server.service. 

Once the installation is finished, you can proceed to the next step.

Start ClickHouse service

Now you can start the ClickHouse service and enable it to start on system reboot with the following command:

systemctl start clickhouse-server systemctl enable clickhouse-server

You can now verify the status of the ClickHouse with the following command:

systemctl status clickhouse-server

You will get the following output:

? clickhouse-server.service - ClickHouse Server (analytic DBMS for big data) Loaded: loaded (/lib/systemd/system/clickhouse-server.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2022-12-05 14:47:40 UTC; 6s ago Main PID: 13369 (clckhouse-watch) Tasks: 205 (limit: 4579) Memory: 65.5M CPU: 1.128s CGroup: /system.slice/clickhouse-server.service ??13369 clickhouse-watchdog "" "" "" "" "" "" "" --config=/etc/clickhouse-server/config.xml --pid-file=/run/clickhouse-server/cl> ??13370 /usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml --pid-file=/run/clickhouse-server/clickhouse-serve> Dec 05 14:47:40 ubuntu2204 systemd[1]: Started ClickHouse Server (analytic DBMS for big data). Dec 05 14:47:40 ubuntu2204 clickhouse-server[13369]: Processing configuration file '/etc/clickhouse-server/config.xml'. Dec 05 14:47:40 ubuntu2204 clickhouse-server[13369]: Logging trace to /var/log/clickhouse-server/clickhouse-server.log Dec 05 14:47:40 ubuntu2204 clickhouse-server[13369]: Logging errors to /var/log/clickhouse-server/clickhouse-server.err.log Dec 05 14:47:41 ubuntu2204 clickhouse-server[13370]: Processing configuration file '/etc/clickhouse-server/config.xml'. Dec 05 14:47:41 ubuntu2204 clickhouse-server[13370]: Saved preprocessed configuration to '/var/lib/clickhouse/preprocessed_configs/config.xml> Dec 05 14:47:41 ubuntu2204 clickhouse-server[13370]: Processing configuration file '/etc/clickhouse-server/users.xml'. Dec 05 14:47:41 ubuntu2204 clickhouse-server[13370]: Merging configuration file '/etc/clickhouse-server/users.d/default-password.xml'. Dec 05 14:47:41 ubuntu2204 clickhouse-server[13370]: Saved preprocessed configuration to '/var/lib/clickhouse/preprocessed_configs/users.xml'.
4.3 ★ | 9 Vote