Using a Client to Connect to a ClickHouse Normal Cluster
You can use SQL to access a cluster on an ECS. For details about how to install the client, see Installing the ClickHouse Client.

The VPC and security group of the cluster to be created must be the same as those of the ECS on the public network. Otherwise, the client cannot access the cluster.
Installing the ClickHouse Client
- Prepare a Linux ECS. For details, see Preparing an ECS.
- Download a client. Log in to the CloudTable console. In the navigation pane on the left, choose Help. In the right pane, click Download Client and Client Verification File to download the client installation package and client verification file.
- Install the client.
- Use the SSH login tool to remotely log in to the Linux ECS through the EIP.
For details, see Logging In to a Linux ECS Using an SSH Password in the Elastic Cloud Server User Guide.
- Go to the root directory of the SSH login tool.
cd /
- Create a folder in the root directory.
mkdir Folder name
- Go to the directory of the created folder.
cd /Folder name/
- Place the client in the directory.
- Decompress the client package.
tar -zxf Client package name
- Decompress the client verification file to the same directory as the client.
- Decompress the client verification file.
cd <Path for storing the client verification file > tar -xzvf Client_sha256.tar.gz
- Obtain the client verification code.
sha256sum ClickHouse_Client_23.3.tar.gz
- Check the verification code in the client verification file and compare it with the client verification code. If they are the same, the client is not tampered with. If they are different, the client is tampered with.
less ClickHouse_Client_23.3.tar.gz.sha256
- Decompress the client verification file.
- Go to the clickhouse folder and load the .so file.
sh install.sh
- Go to the bin directory.
cd bin/
Grant the 700 permission to the directory.
chmod 700 clickhouse
- Use the SSH login tool to remotely log in to the Linux ECS through the EIP.
- After the client is installed, run the following command to connect to the ClickHouse cluster. For details about the port, see Table 1.
./clickhouse client --host Internal IP address of the cluster --port 9000 --user admin --password Password
- Internal IP address of the cluster: cluster access address on the cluster details page. Replace it with the access address of the cluster you purchased.
- Password: the password set when you purchase the cluster. If there are special characters, use backslashes (\) to escape them. If the password is enclosed in single quotation marks ('), the special characters do not need to be escaped.
Table 1 Custom security rules Direction
Action
Port/Range
Type
Destination/Source Address
Usage
Outbound
Allow
All
IPv4/IPv6
0.0.0.0/0
Permit in the outbound direction
Inbound
Allow
8123
Security group of the CloudTable ClickHouse cluster
ClickHouse HTTP port number
Allow
9000
ClickHouse TCP port number
Allow
8443
ClickHouse HTTPS port number
Allow
9440
Secure TCP security port of ClickHouse
Getting Started with ClickHouse
- Create a database.
create database demo;
- Use the database.
use demo;
- Check the database in use.
select currentDatabase();
- Create a table.
create table demo_t(uid Int32,name String,age UInt32,gender String)engine = TinyLog;
- View the table structure.
desc demo_t;
- Insert data.
insert into demo_t values(1,'Candy','23','M'),(2,'cici','33','F');
- View the table.
select * from demo_t;
- View the database and table.
- View the database.
show databases;
- View the table.
show tables;
- View the database.
- Delete the database and table.
- Delete the table.
drop table demo_t;
- Before deleting a table, check whether the table is in use.
- After a table is deleted, it can be restored within 24 hours. The restoration command is as follows:
set allow_experimental_undrop_table_query = 1;
UNDROP TABLE Table name;
- Delete the database.
drop database demo;
- Delete the table.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot