My FeedDiscussionsHashnode Enterprise
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

ClickHouse Server in 1 minute with Docker

Titronium's photo
Titronium
·Mar 4, 2021·

3 min read

ClickHouse is an open-source column-oriented DBMS (developed by Yandex). ClickHouse works 100-1000x faster than traditional approaches. It's good for Big Data, business analytics and time series data. ClickHouse is the first open source SQL data warehouse to match the performance, maturity, and scalability of proprietary databases like Sybase IQ, Vertica, and Snowflake.

In this little tutorial, I will show you how to install ClickHouse with minimal settings.

For this tutorial, we will need Docker and docker-compose to be installed.

First, you need to create a directory in which to create the necessary files and directories.

cd /home/username
mkdir my-clickhouse
cd my-clickhouse

Then you need to create a directory in which ClickHouse data will be stored.

mkdir db

The final step is to create the docker-compose.yml file.

version: '3'

services:
  ch_server:
    image: yandex/clickhouse-server
    ports:
      - "8123:8123"
    volumes:
      - ./db:/var/lib/clickhouse
    networks:
        - ch_ntw

  ch_client:
    image: yandex/clickhouse-client
    entrypoint:
      - /bin/sleep
    command:
      - infinity
    networks:
        - ch_ntw

networks:
  ch_ntw:
    driver: bridge
    ipam:
      config:
        - subnet: 10.222.1.0/24

Let's check what we did. One file (docker-compose.yml) and one directory (db).

ls -la

drwxr-xr-x 3 user user 4096 Mar  4 07:44 .
drwxr-xr-x 4 user user 4096 Mar  4 07:43 ..
drwxr-xr-x 3 user user 4096 Mar  4 07:45 db
-rw-r--r-- 1 user user  435 Mar  4 07:46 docker-compose.yml

That's it!

Now let's start our Clickhouse Server. The ClickHouse image will download itself and the process will start.

sudo docker-compose up -d

Now let's open the command line.

sudo docker-compose exec ch_server clickhouse-client

We should see the result of running ClickHouse.

ClickHouse client version 21.2.5.5 (official build).
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 21.2.5 revision 54447.

5175e561dffd :)

Congratulations, ClickHouse is installed successfully.

This is a very simple guide to playing with ClickHouse DB. I will probably write a more serious guide on how to configure ClickHouse later.

Original post: twiwoo.com/docker/clickhouse-server-in-1-m…