Importing and Configuring ClickHouse Sample Projects
Context
Obtain the ClickHouse development sample project and import the project to IntelliJ IDEA to learn the sample project.
Prerequisites
Ensure that the difference between the local PC time and the cluster time is less than 5 minutes. If the time difference cannot be determined, contact the system administrator. You can view the time of the cluster in the lower-right corner on the FusionInsight Manager page.
Scenarios
ClickHouse provides sample projects for multiple scenarios to help you quickly learn ClickHouse projects.
Procedure
- Obtain the sample project folder clickhouse-examples and Maven configurations in the src directory where the sample code is decompressed. For details, see Obtaining the MRS Application Development Sample Project.
- In the application development environment, import the sample project to the IntelliJ IDEA development environment.
- On the IDEA page, choose File > New > Project from Existing Sources.
- In the displayed Select File or Directory to Import dialog box, select the pom.xml file in the clickhouse-examples folder and click OK.
- Confirm subsequent configurations and click Next. If there is no special requirement, use the default values.
- Select the recommended JDK version and click Finish.
- On the IDEA page, choose File > New > Project from Existing Sources.
- After the project is imported, modify the clickhouse-example.properties file in the conf directory of the sample project based on the actual environment information.
loadBalancerIPList= sslUsed=false loadBalancerHttpPort=21425 loadBalancerHttpsPort=21426 CLICKHOUSE_SECURITY_ENABLED=true user= # Passwords stored in plaintext pose security risks. Store them in ciphertext in configuration files or environment variables. password= clusterName=default_cluster databaseName=testdb tableName=testtb batchRows=10000 batchNum=10
Table 1 Configuration description Parameter
Default Value
Definition
loadBalancerIPList
-
Mandatory. Set this parameter to the IP address list of LoadBalance.
Log in to FusionInsight Manager, choose Cluster > Services > ClickHouse > Instance, and check the service IP addresses of all ClickHouseBalancer instances.
Use commas (,) to separate multiple IP addresses, for example, 10.10.10.100,10.10.10.101.
sslUsed
false
Whether to enable SSL encryption. You are advised to set this parameter to true for clusters in security mode.
loadBalancerHttpPort
21425
HTTP port number of LoadBalance.
Log in to FusionInsight Manager, choose Cluster > Services > ClickHouse > Instance, click the corresponding ClickHouseBalancer instance, choose Instance Configurations > All Configurations, search for lb_http_port, and obtain the parameter value. The default value is 21425.
loadBalancerHttpsPort
21426
HTTPS port number of LoadBalance. If sslUsed is set to true, this parameter cannot be empty.
Log in to FusionInsight Manager, choose Cluster > Services > ClickHouse > Instance, click the corresponding ClickHouseBalancer instance, choose Instance Configurations > All Configurations, search for lb_https_port, and obtain the parameter value. The default value is 21426.
CLICKHOUSE_SECURITY_ENABLED
true
Whether to enable the security mode. Set this parameter to false for a cluster in normal mode.
user
No default value
Developer user created in Table 1.
password
No default value
Password of the development user
Passwords stored in plaintext pose security risks. Store them in ciphertext in configuration files or environment variables.
NOTE:If the user is created on FusionInsight Manager, you need to change the initial password upon the first login.
clusterName
default_cluster
ClickHouse logical cluster name. Retain the default value.
databaseName
testdb
Name of the database to be created in the sample code project. You can change the database name based on the site requirements.
tableName
testtb
Name of the table to be created in the sample code project. You can change the table name based on the site requirements.
batchRows
10000
Number of data records written in a batch.
batchNum
10
Total number of batches in which data is written.
Although ClickHouse has the cluster capability, it does not have a unified access entry. The client needs to directly detect all nodes in the cluster. This is not easy to use. ClickHouse uses the LoadBalance-based deployment architecture to automatically distribute user access traffic to multiple backend nodes, expanding service capabilities to external systems and improving fault tolerance. When a client application requests a cluster, Nginx-based ClickHouseBalancer is used to distribute traffic. In this way, data read/write load and high availability of application access are guaranteed.
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