Table of Contents
ClickHouse is a high-performance column-oriented database designed for real-time analytics and large-scale data processing. Installing it on Ubuntu is straightforward using the official ClickHouse repository.
Step 1: Update System Packages
Start by updating your system to avoid dependency issues.
sudo apt update && sudo apt upgrade -y
Step 2: Install Required Dependencies
ClickHouse requires HTTPS support and basic tools.
sudo apt install -y apt-transport-https ca-certificates curl gnupg
Step 3: Add the ClickHouse Repository
Import the official ClickHouse GPG key:
curl -fsSL https://packages.clickhouse.com/CLICKHOUSE-KEY.GPG | sudo gpg --dearmor -o /usr/share/keyrings/clickhouse.gpg
Add the repository to APT sources:
echo "deb [signed-by=/usr/share/keyrings/clickhouse.gpg] https://packages.clickhouse.com/deb stable main" | sudo tee /etc/apt/sources.list.d/clickhouse.list
Update package lists:
sudo apt update
Step 4: Install ClickHouse Server and Client
Install both the server and CLI client:
sudo apt install -y clickhouse-server clickhouse-client
Step 5: Start and Enable ClickHouse Service
Enable ClickHouse to start on boot and run it immediately:
sudo systemctl enable --now clickhouse-server
Check service status:
systemctl status clickhouse-server
You should see active (running).
Step 6: Connect to ClickHouse
Use the ClickHouse client to connect locally:
clickhouse-client
Test with a simple query:
SELECT version();
If a version is returned, ClickHouse is working correctly.
Step 7: Configure Network Access (Optional)
By default, ClickHouse listens on localhost only.
Edit the config file:
sudo nano /etc/clickhouse-server/config.xml
Find and update:
<listen_host>::</listen_host>
Restart the service:
sudo systemctl restart clickhouse-server
Open the default port if UFW is enabled:
sudo ufw allow 9000/tcp
ClickHouse is optimized for analytical queries, not transactional workloads. Use it for logs, metrics, analytics, and event data — not as a drop-in replacement for MySQL or PostgreSQL.
