DEV Community

loading...

ClickHouse Server in 1 minute with Docker

Titronium
PHP and JS programmer
・2 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
Enter fullscreen mode Exit fullscreen mode

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


mkdir db

Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode

Now let's open the command line.


sudo docker-compose exec ch_server clickhouse-client

Enter fullscreen mode Exit fullscreen mode

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 :)

Enter fullscreen mode Exit fullscreen mode

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: https://twiwoo.com/docker/clickhouse-server-in-1-minute-with-docker/

Discussion (0)