Quick Start
Create Cluster
- Log in to UCloud Global account and go to User Console , search under All Products or select “Data Warehouse UDW Clickhouse” under Data Warehouse, and enter the UClickhouse console under Data Warehouse.
- Click to create a cluster, enter the cluster creation page, and select the required configuration according to actual needs and purchase as prompted on the page. For explanation of each configuration item, see Configuration Description.
Configuration Description
Configuration Item | Description |
---|---|
Region |
Supports regions including North China 1, Shanghai 2, Guangzhou, Hong Kong, Singapore, and Tokyo. It is recommended to choose the appropriate region according to the principle of proximity to the business.
Note: Once the region is selected, it cannot be modified after purchase. |
Availability Zone | Different availability zones are in different geographic areas. Choose according to actual circumstances. |
Version | Select the kernel version according to actual needs |
CPU/Memory |
Supports two computing specifications, standard and compute-intensive, which can be selected according to actual business needs. For production environments, it is recommended to choose a higher resource configuration specification.
|
Cloud Disk Type | Clickhouse's storage characteristics require high disk throughput. To ensure the performance advantage of Clickhouse, only RSSD cloud disks are provided. |
Cloud Disk Capacity | The default cloud disk capacity of the cluster is 200G, with a maximum support of 32000G. If the data volume is relatively large, it is recommended to increase the capacity. |
Replicas |
The dual-replica mode has high availability features. Two replica nodes form a shard, and when a node in the shard is unavailable, the other node can continue to provide service capability (needs to be used in conjunction with the replica table engine). The single-replica mode does not promise SLA and is recommended for use only in test/development environments. Dual-replica mode is recommended for production environments. |
Number of Nodes | Dual-replica mode supports 2 nodes and 4 nodes. Single-replica mode supports only 1 node. |
Network |
VPC (Virtual Private Cloud) is a user-owned, logically isolated network environment. For each region, we will create a default VPC and default subnet. Users can directly create clusters in the default VPC. |
View Cluster Information
After the cluster is created and started successfully, you can enter the UClickhouse console under Data Warehouse, select the region and availability zone where the cluster is located, and view the cluster list and detailed information.
Use UClickhouse Cloud Data Warehouse
Connect to the Cluster
-
Establish a cloud host in the region where the cluster is located (within the same subnet), and install Clickhouse-client on the cloud host. Official old version download link: Download Clickhouse-client . Official new version download link: Download Clickhouse-client .
It is recommended to choose the Clickhouse-client version according to the kernel version created, for example, if the created cluster kernel version is 21.8.14.5, download the following rpm package:
Official old version download wget https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-client-21.8.14.5-2.noarch.rpm wget https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-common-static-21.8.14.5-2.x86_64.rpm Official new version download wget https://packages.clickhouse.com/rpm/lts/clickhouse-client-22.3.6.5.noarch.rpm wget https://packages.clickhouse.com/rpm/lts/clickhouse-common-static-22.3.6.5.x86_64.rpm
-
Execute installation
rpm -ivh clickhouse-common-static-21.8.14.5-2.x86_64.rpm rpm -ivh clickhouse-client-21.8.14.5-2.noarch.rpm
-
Connect to the cluster through clickhouse-client
clickhouse-client --host=<any node IP address> --port=9000 --user=admin --password=<password set when creating the cluster>
The above command will enter interactive mode. The default username is admin, the default port is 9000, and the node IP can be viewed in cluster details.
Create Database and Data Table
Use clickhouse-client to enter interactive mode and connect to the cluster to execute DDL statements
- Create database and table in dual-replica mode
CREATE DATABASE IF NOT EXISTS ck_test ON CLUSTER ck_cluster;
CREATE TABLE ck_test.lineorder ON CLUSTER ck_cluster
(
LO_ORDERKEY UInt32,
LO_LINENUMBER UInt8,
LO_CUSTKEY UInt32,
LO_PARTKEY UInt32,
LO_SUPPKEY UInt32,
LO_ORDERDATE Date,
LO_ORDERPRIORITY LowCardinality(String),
LO_SHIPPRIORITY UInt8,
LO_QUANTITY UInt8,
LO_EXTENDEDPRICE UInt32,
LO_ORDTOTALPRICE UInt32,
LO_DISCOUNT UInt8,
LO_REVENUE UInt32,
LO_SUPPLYCOST UInt32,
LO_TAX UInt8,
LO_COMMITDATE Date,
LO_SHIPMODE LowCardinality(String)
)
ENGINE = ReplicatedMergeTree(
'/clickhouse/ck_test/tables/{layer}-{shard}/lineorder',
'{replica}'
) ORDER BY (LO_ORDERKEY);
- Create database and table in single-replica mode
CREATE DATABASE IF NOT EXISTS ck_test;
CREATE TABLE ck_test.lineorder
(
LO_ORDERKEY UInt32,
LO_LINENUMBER UInt8,
LO_CUSTKEY UInt32,
LO_PARTKEY UInt32,
LO_SUPPKEY UInt32,
LO_ORDERDATE Date,
LO_ORDERPRIORITY LowCardinality(String),
LO_SHIPPRIORITY UInt8,
LO_QUANTITY UInt8,
LO_EXTENDEDPRICE UInt32,
LO_ORDTOTALPRICE UInt32,
LO_DISCOUNT UInt8,
LO_REVENUE UInt32,
LO_SUPPLYCOST UInt32,
LO_TAX UInt8,
LO_COMMITDATE Date,
LO_SHIPMODE LowCardinality(String)
)
ENGINE = MergeTree ORDER BY (LO_ORDERKEY);
Prepare Data and Import
Create a csv file lineorder.csv and place it in the previously created cloud host data disk /data directory
1,1,7381,155190,828,"1996-01-02","5-LOW",0,17,2116823,17366547,4,2032150,74711,2,"1996-02-12","TRUCK",
1,2,7381,67310,163,"1996-01-02","5-LOW",0,36,4598316,17366547,9,4184467,76638,6,"1996-02-28","MAIL",
1,3,7381,63700,71,"1996-01-02","5-LOW",0,8,1330960,17366547,10,1197864,99822,2,"1996-03-05","REG AIR",
1,4,7381,2132,943,"1996-01-02","5-LOW",0,28,2895564,17366547,9,2634963,62047,6,"1996-03-30","AIR",
1,5,7381,24027,1625,"1996-01-02","5-LOW",0,24,2282448,17366547,10,2054203,57061,4,"1996-03-14","FOB",
1,6,7381,15635,1368,"1996-01-02","5-LOW",0,32,4962016,17366547,7,4614674,93037,2,"1996-02-07","MAIL",
2,1,15601,106170,1066,"1996-12-01","1-URGENT",0,38,4469446,4692918,0,4469446,70570,5,"1997-01-14","RAIL",
3,1,24664,4297,1959,"1993-10-14","5-LOW",0,45,5405805,19384625,6,5081456,72077,0,"1994-01-04","AIR",
3,2,24664,19036,1667,"1993-10-14","5-LOW",0,49,4679647,19384625,10,4211682,57301,0,"1993-12-20","RAIL",
3,3,24664,128449,1409,"1993-10-14","5-LOW",0,27,3989088,19384625,6,3749742,88646,7,"1993-11-22","SHIP",
Use clickhouse-client in non-interactive mode to execute the following command to import data
clickhouse-client --host=<any node IP address> --port=9000 --user=admin --password=<password set when creating the cluster> --database=ck_test --query "INSERT INTO lineorder FORMAT CSV" < /data/lineorder.csv
Query Data
-
Use clickhouse-client in non-interactive mode to execute queries
clickhouse-client --host=<any node IP address> --port=9000 --user=admin --password=<password set when creating the cluster> --database=ck_test --query="select * from lineorder"
-
Use clickhouse-client in interactive mode to execute queries
clickhouse-client --host=<any node IP address> --port=9000 --user=admin --password=<password set when creating the cluster> --database=ck_test
-
Use http, with port 8123, to perform queries
echo "select * from ck_test.lineorder" | curl 'http://username:password@any node IP address:8123/' --data-binary @-