How to Install and Configure ClickHouse on Rocky Linux/CentOS with Remote Access
This step‑by‑step guide shows how to add the Yandex repository, install ClickHouse server and client on Rocky Linux or CentOS, configure the service, test local connections, create databases, enable remote access, and verify the setup, all within 15‑20 minutes.
ClickHouse is a high‑performance column‑oriented DBMS designed for OLAP and real‑time analytics in big‑data scenarios. This article explains how to install and configure ClickHouse on yum‑based systems such as Rocky Linux or CentOS and enable remote access.
Applicable systems : Rocky Linux 8/9, CentOS 7/8 Estimated time : 15–20 minutes Required permissions : root or sudo
🔧 Step 1: Add Yandex Official Repository
The default system repositories do not contain ClickHouse packages, so you must add the official RPM repository manually:
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://packages.clickhouse.com/rpm/clickhouse.repoyum‑utils provides the yum-config-manager tool for managing repositories, and the added repository is maintained by Yandex.
📦 Step 2: Install ClickHouse Server and Client
After adding the repository, install the packages:
sudo yum install -y clickhouse-server clickhouse-client clickhouse-serveris the server program, while clickhouse-client is the command‑line client used to connect and operate the database.
▶️ Step 3: Start and Enable the ClickHouse Service
Start the service and enable it to start on boot:
sudo systemctl start clickhouse-server # start service
sudo systemctl enable clickhouse-server # enable on bootCheck the service status with: sudo systemctl status clickhouse-server The service is considered running when the status shows active (running).
🧪 Step 4: Test Local Connection
Use the client to connect locally: clickhouse-client Default connection parameters are:
Host: localhost
Port: 9000
User: default
Password: (none)Configuration files are located at:
/etc/clickhouse-server/config.xml (main config)
/etc/clickhouse-server/users.xml (user config)
/var/lib/clickhouse (data directory)
➕ Optional Step 5: Create Database and Table
After entering the client, you can create a database, a table, and insert data:
CREATE DATABASE mydb; -- create database
USE mydb; -- switch to it
CREATE TABLE users (
id UInt32,
name String,
age UInt8
) ENGINE = MergeTree ORDER BY id; -- create table
INSERT INTO users VALUES (1, 'Alice', 30), (2, 'Bob', 25); -- insert data
SELECT * FROM users; -- query data🌐 Step 6: Configure Remote Access (Important)
ClickHouse listens only on 127.0.0.1 by default. To allow external connections, modify the configuration:
Edit the main config file:
sudo vi /etc/clickhouse-server/config.xml
<!-- Add or modify the <listen_host> tag -->
<listen_host>0.0.0.0</listen_host>0.0.0.0 permits connections from any IPv4 address. For tighter security, specify a particular IP or subnet and comment out IPv6 entries such as ::1 .
Open firewall ports (default 9000/tcp for native protocol and 8123/tcp for HTTP):
sudo firewall-cmd --add-port=9000/tcp --permanent
sudo firewall-cmd --add-port=8123/tcp --permanent
sudo firewall-cmd --reloadCloud users must also open these ports in their security groups.
Edit the user config file to allow remote users and set a password:
sudo vi /etc/clickhouse-server/users.xml
<networks>
<ip>::/0</ip> <!-- allow all IPs; replace with specific range for security -->
</networks>
<password>your_password</password> <!-- set a strong password -->Replace ::/0 with a specific CIDR block (e.g., 192.168.1.0/24 ) to improve security.
Restart the service to apply changes:
sudo systemctl restart clickhouse-server🖥️ Step 7: Remote Connection Test
From any host, test the remote connection using:
clickhouse-client --host 127.0.0.1 --user default --password your_passwordParameters:
--host: target server address (can be a public IP)
--user: username, default is "default"
--password: the password you set✅ Summary
By following these steps you have installed ClickHouse, performed basic configuration, and enabled remote access, allowing you to build OLAP applications or integrate ClickHouse into your data platform.
Note : Default memory and disk settings may not suit production; adjust them according to workload. Always set strong passwords and restrict allowed IP ranges to ensure security.
Xiao Liu Lab
An operations lab passionate about server tinkering 🔬 Sharing automation scripts, high-availability architecture, alert optimization, and incident reviews. Using technology to reduce overtime and experience to avoid major pitfalls. Follow me for easier, more reliable operations!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
