What is a clear procedure to deploy ClickHouse on a Linux distribution for modest analytics workloads?
0 reputation · 12 May 2021, 19:07 UTC
0 reputation · 12 May 2021, 19:07 UTC
I am seeking a reliable method to install and configure ClickHouse on a typical Linux system (such as Ubuntu or CentOS) to support a modest analytics workload. The deployment should cover prerequisite packages, repository or binary installation, service configuration, basic tuning parameters, and verification that the server accepts queries, while also noting differences between deb/rpm packages and the binary tarball approach.
Which prerequisite packages are required for ClickHouse on Ubuntu versus CentOS? How do I configure the ClickHouse service and apply basic tuning settings appropriate for a modest workload? What steps verify that the server is ready to accept queries, and how can I roll back the installation if it fails?
26525 reputation · 13 May 2021, 05:19 UTC
To deploy ClickHouse for a modest analytics workload, use the official repository packages to ensure systemd integration and dependency management.
wget gnupg lsb-releasewget gnupg yum-utilsUbuntu/Debian:
# Import GPG key
sudo wget -O - https://packages.clickhouse.com/deb CLICKHOUSE-KEY.GPG | sudo apt-key add -
# Add repository
echo 'deb https://packages.clickhouse.com/deb stable main' | sudo tee /etc/apt/sources.list.d/clickhouse.list
sudo apt-get update
CentOS/RHEL:
# Import GPG key
sudo rpm --import https://packages.clickhouse.com/rpm CLICKHOUSE-KEY.GPG
# Add repository
sudo tee /etc/yum.repos.d/clickhouse.repo <
# Ubuntu/Debian
sudo apt-get install -y clickhouse-server clickhouse-client
# CentOS/RHEL
sudo yum install -y clickhouse-server clickhouse-client
# Enable and start service
sudo systemctl enable clickhouse-server
sudo systemctl start clickhouse-server
For modest workloads, modify /etc/clickhouse-server/config.xml or create a override file in /etc/clickhouse-server/config.d/ with these parameters:
listen_host: Set to 0.0.0.0 for remote access or 127.0.0.1 for local-only access.max_concurrent_queries: Set to 16 to prevent resource exhaustion.max_memory_usage: Limit this to roughly 50% of total system RAM (e.g., 1000000000 for ~1GB on a 2GB machine) to avoid swapping.Apply changes with: sudo systemctl restart clickhouse-server
sudo systemctl status clickhouse-server (should be active/running).ss -tlnp | grep clickhouse (verify ports 9000 and 8123).clickhouse-client --query 'SELECT version();'clickhouse-client --query 'SELECT * FROM system.tables LIMIT 5;'sudo systemctl stop clickhouse-server
# Ubuntu/Debian
sudo apt-get purge -y clickhouse-server clickhouse-client
# CentOS/RHEL
sudo yum remove -y clickhouse-server clickhouse-client
# Cleanup
sudo rm -f /etc/apt/sources.list.d/clickhouse.list /etc/yum.repos.d/clickhouse.repo
Deb/RPM Packages: Recommended for most users. They automate systemd unit creation, user permission setup for /var/lib/clickhouse, and dependency resolution.
Binary Tarball: Provides a portable executable but requires manual configuration of ulimit (open files should be at least 262,144), manual systemd service file creation, and manual directory permission management.
Use comments to ask for clarification. Post a solution as an answer.
26,525 reputation · 13 May 2021, 00:47 UTC
While the previous response correctly identifies the primary configuration files, it is important to emphasize the use of the config.d/ and users.d/ directories for modest workloads. Modifying the main config.xml directly can make package updates difficult and increases the risk of accidental syntax errors that prevent the server from starting.
Instead of editing the main file, create a small XML file (e.g., /etc/clickhouse-server/config.d/tuning.xml) containing only the parameters you wish to change:
<clickhouse>
<max_concurrent_queries>16</max_concurrent_queries>
<max_memory_usage>1000000000</max_memory_usage>
</clickhouse>
To verify that these overrides are active without restarting the service, you can query the system.settings table via the client:
clickhouse-client --query "SELECT name, value FROM system.settings WHERE name = 'max_memory_usage'"
This approach ensures that your custom tuning persists across version updates and provides a clear audit trail of changes.