ClickHouse is an open-source columnar database management system designed for real-time analytical queries over large datasets. Unlike row-oriented databases such as MySQL or PostgreSQL, ClickHouse stores data by column, allowing it to scan only the columns needed for a query and apply aggressive compression, resulting in query performance orders of magnitude faster for analytical workloads. It is well-suited for time-series data, event logs, financial aggregations, and business intelligence dashboards. This tutorial walks through installing ClickHouse on RHEL 8, performing basic operations, and understanding when it is the right tool for the job.

Prerequisites

  • RHEL 8 server with at least 4 GB RAM and 20 GB free disk space
  • Root or sudo privileges
  • firewalld installed and running
  • Basic familiarity with SQL syntax

Step 1 — Add the ClickHouse Repository

ClickHouse provides an official RPM repository for RHEL-based systems. Add the repository and import the signing key so dnf can verify package integrity.

dnf install -y yum-utils

yum-config-manager --add-repo https://packages.clickhouse.com/rpm/clickhouse.repo

# Verify repo was added
dnf repolist | grep clickhouse

Step 2 — Install ClickHouse Server and Client

Install both the server daemon and the command-line client. The installer creates the clickhouse system user and sets up default data and log directories under /var/lib/clickhouse and /var/log/clickhouse-server.

dnf install -y clickhouse-server clickhouse-client

# Enable and start the server
systemctl enable --now clickhouse-server

# Confirm the service is running
systemctl status clickhouse-server

Step 3 — Configure the Listen Host

By default, ClickHouse binds only to 127.0.0.1. To allow remote connections, edit /etc/clickhouse-server/config.xml and uncomment or add the listen_host directive. Restart the service after making changes.

# In /etc/clickhouse-server/config.xml, locate and set:
#
#   0.0.0.0
#
# Use sed to make the change without opening the full XML file:

sed -i 's|<!-- 0.0.0.0 -->|0.0.0.0|' 
  /etc/clickhouse-server/config.xml

systemctl restart clickhouse-server

Step 4 — Basic ClickHouse Client Usage

Connect to the local server with clickhouse-client and run DDL and DML statements. ClickHouse SQL is largely ANSI-compatible with extensions for time-series and aggregation functions.

# Open interactive client
clickhouse-client

-- Create a database
CREATE DATABASE analytics;

-- Switch to the new database
USE analytics;

-- Create a table using the MergeTree engine (standard for most use cases)
CREATE TABLE web_events (
    event_date  Date,
    event_time  DateTime,
    user_id     UInt32,
    page        String,
    duration_ms UInt16
) ENGINE = MergeTree()
ORDER BY (event_date, user_id);

-- Insert sample rows
INSERT INTO web_events VALUES
  (today(), now(), 101, '/home',    1200),
  (today(), now(), 102, '/pricing', 3400),
  (today(), now(), 101, '/docs',    800);

-- Aggregation query — total and average time per page
SELECT
    page,
    count()            AS visits,
    sum(duration_ms)   AS total_ms,
    avg(duration_ms)   AS avg_ms
FROM web_events
GROUP BY page
ORDER BY visits DESC;

Step 5 — Open the Firewall

ClickHouse uses port 8123 for the HTTP interface and port 9000 for the native binary protocol used by clickhouse-client and most drivers. Open both ports in firewalld if remote access is required.

# Native protocol (clickhouse-client, JDBC/ODBC drivers)
firewall-cmd --permanent --add-port=9000/tcp

# HTTP interface (curl, Grafana, Superset)
firewall-cmd --permanent --add-port=8123/tcp

firewall-cmd --reload

# Test HTTP interface from a remote host
curl http://:8123/?query=SELECT+version()

Step 6 — ClickHouse Use Cases: Analytics vs OLTP

Understanding the differences between OLAP and OLTP workloads prevents costly architectural mistakes.

-- ClickHouse EXCELS at (OLAP):
--   Aggregating billions of rows in seconds
--   Time-series dashboards (Grafana, Redash)
--   Log analytics (replacing ELK for pure aggregations)
--   Financial reporting with GROUP BY + window functions

SELECT
    toStartOfHour(event_time) AS hour,
    count()                   AS events_per_hour
FROM web_events
WHERE event_date >= today() - 7
GROUP BY hour
ORDER BY hour;

-- ClickHouse is NOT suited for (OLTP):
--   Frequent single-row updates or deletes
--   High-concurrency transactional writes
--   JOIN-heavy normalized schemas with small tables
--   Applications requiring row-level ACID transactions

Conclusion

You now have ClickHouse installed and running on RHEL 8, with the server accessible over both its native and HTTP interfaces. The MergeTree engine family handles the vast majority of analytical use cases, offering fast ingest and sub-second query times on large datasets. ClickHouse is not a replacement for transactional databases like MySQL or PostgreSQL, but it is an excellent complement for the reporting and analytics layer of your data architecture.

Next steps: How to Set Up ClickHouse Replication on RHEL 8, How to Connect Grafana to ClickHouse on RHEL 8, and How to Migrate Data from MySQL to ClickHouse on RHEL 8.