Install ClickHouse with APT or Docker, verify the setup, and integrate it with PostgreSQL for fast analytics.
Use a 64-bit Ubuntu 20.04+ host with sudo rights and open ports 9000 (native) and 8123 (HTTP). For Docker, install Docker 20.10+ and Docker Compose.
Add the GPG key:sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E0C56BD4
Add the repo:echo "deb https://packages.clickhouse.com/deb stable main" | sudo tee /etc/apt/sources.list.d/clickhouse.list
Update & install:sudo apt-get update && sudo apt-get install clickhouse-server clickhouse-client
Start the service:sudo service clickhouse-server start
Test instance:docker run --name ch_test -d -p 9000:9000 -p 8123:8123 yandex/clickhouse-server
Production with volumes:docker run --name clickhouse -d -p 9000:9000 -p 8123:8123 -v /opt/clickhouse/data:/var/lib/clickhouse -v /opt/clickhouse/log:/var/log/clickhouse-server yandex/clickhouse-server
Connect:clickhouse-client
or docker exec -it clickhouse clickhouse-client
Run SELECT version();
to confirm the server is up.
CREATE DATABASE shop;
USE shop;
CREATE TABLE Orders (id UInt32, customer_id UInt32, order_date Date, total_amount Decimal(10,2)) ENGINE = MergeTree ORDER BY id;
Install clickhouse_fdw
in PostgreSQL, then create foreign tables pointing to ClickHouse. This lets PostgreSQL query large ClickHouse datasets while keeping OLTP writes local.
Store data on dedicated SSDs, enable backups, monitor system.query_log
, and use ReplicatedMergeTree for HA. Set TTLs to auto-purge old partitions.
1. Skipping the GPG key causes apt 404 errors.
2. Running Docker without volume mounts erases data when the container is removed.
Yes. ClickHouse is Apache 2.0 licensed and fully open source.
No. Keep OLTP workloads in PostgreSQL and replicate data to ClickHouse for OLAP queries.
Use clickhouse-client --query
with INFILE
, clickhouse-copier
, or CDC pipelines such as Debezium.
Yes. ClickHouse is Apache 2.0 licensed and free for commercial use.
No. ClickHouse specializes in OLAP analytics; PostgreSQL remains the OLTP system of record.
Use clickhouse-client
with CSV/TSV, clickhouse-copier
, or real-time CDC tools like Debezium.