ClickHouse - How to connect to a ClickHouse cluster
Objective
ClickHouse is an open-source, columnar analytical database system designed for real-time processing of massive data volumes, providing high performance, scalability, and low latency.
This guide explains how to connect to a ClickHouse cluster using the native CLI, HTTPS, and MySQL protocols.
Requirements
- Access to the OVHcloud Control Panel.
- A Public Cloud project in your OVHcloud account.
- A ClickHouse cluster running on OVHcloud Public Cloud and accepting incoming connections.
Instructions
Verify that your public IP address is part of the "Authorised IPs" defined for this ClickHouse service.
Check also that the user has the required ACLs for the target databases.
Downloading server and user certificates
To connect to the ClickHouse service, you need server and user certificates.
- Server certificate: The server Certificate Authority (CA) certificate can be downloaded from the
Dashboardtab. - User certificate and access key: The user certificate and the user access key can be downloaded from the
Userstab.
Connection methods
You can connect to a ClickHouse cluster using different protocols and ports:
| Protocol | Port | Tool |
|---|---|---|
| ClickHouse Native | 20184 | clickhouse-client |
| ClickHouse HTTPS | 20185 | curl or any HTTP client |
| ClickHouse MySQL | 20186 | mysql |
The hostname, ports and credentials for your cluster are available in the Dashboard tab of the OVHcloud Control Panel.
Connecting using the ClickHouse native protocol (port 20184)
Connect using the official clickhouse-client CLI. For installation details, see the official ClickHouse Client documentation.
Replace <password> with your actual password and the hostname with the one from your cluster dashboard.
ClickHouse Client configuration file
You can configure the ClickHouse Client using an XML or YAML file to simplify connection. The client searches for configuration files in the following order:
- A file specified with
-c/--config/--config-file. ./clickhouse-client.[xml|yaml|yml].$XDG_CONFIG_HOME/clickhouse/config.[xml|yaml|yml](or~/.config/clickhouse/config.[xml|yaml|yml]if XDG_CONFIG_HOME is not set).~/.clickhouse-client/config.[xml|yaml|yml]./etc/clickhouse-client/config.[xml|yaml|yml].
Example XML configuration
Create a file named clickhouse-client.xml with the following content:
For more information, see the sample official configuration file.
Example YAML configuration
Create a file named clickhouse-client.yml with the following minimal content:
Change these values according to your own cluster configuration.
Inserting data into ClickHouse using the ClickHouse native CLI
For this first example, let's insert a test row into the my_table table in the test_db database.
Querying data from ClickHouse using the ClickHouse native CLI
Retrieve all the data from the my_table table in the test_db database:
Connecting using HTTPS (port 20185)
Connect using curl or any HTTP client over HTTPS:
Replace <password> with your actual password and the hostname with the one from your cluster dashboard.
Connecting using the MySQL protocol (port 20186)
Connect using the standard mysql client over the MySQL-compatible interface:
Replace <password> with your actual password and the hostname with the one from your cluster dashboard.
Go further
We would love to help answer questions and appreciate any feedback you may have.
If you need training or technical assistance to implement our solutions, contact your sales representative or click on this link to get a quote and ask our Professional Services experts for a custom analysis of your project.
Are you on Discord? Connect to our channel at https://discord.gg/ovhcloud and interact directly with the team that builds our Analytics service!
Join our community of users.