Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

ClickHouse Cluster Configuration

Updated on 2022-12-02 GMT+08:00

Background

ClickHouse uses the multi-shard and multi-replica deployment architecture to implement the cluster high availability. Multiple shards are defined in each cluster, and each shard has two or more replicas. If a node is faulty, replicas on other nodes in the shard can take over services from the faulty node, ensuring service continuity and improving cluster stability.

NOTE:

This section applies only to MRS 3.1.0.

Cluster Configuration

  1. Log in to Manager and choose Cluster > Services > ClickHouse > Configurations > All Configurations.
  2. Add the custom configuration items in Table 1 to the clickhouse-metrika-customize parameter.

    Table 1 Custom parameters

    Parameter

    Value

    clickhouse_remote_servers.example_cluster.shard[1].replica[1].host

    host1.9bf17e66-e7ed-4f21-9dfc-34575f955ae6.com

    clickhouse_remote_servers.example_cluster.shard[1].replica[1].port

    9000

    clickhouse_remote_servers.example_cluster.shard[1].replica[2].host

    host2.9bf17e66-e7ed-4f21-9dfc-34575f955ae6.com

    clickhouse_remote_servers.example_cluster.shard[1].replica[2].port

    9000

    clickhouse_remote_servers.example_cluster.shard[1].internal_replication

    true

    clickhouse_remote_servers.example_cluster.shard[2].replica[1].host

    host3.9bf17e66-e7ed-4f21-9dfc-34575f955ae6.com

    clickhouse_remote_servers.example_cluster.shard[2].replica[1].port

    9000

    clickhouse_remote_servers.example_cluster.shard[2].replica[2].host

    host4.9bf17e66-e7ed-4f21-9dfc-34575f955ae6.com

    clickhouse_remote_servers.example_cluster.shard[2].replica[2].port

    9000

    clickhouse_remote_servers.example_cluster.shard[2].internal_replication

    true

  3. Click Save.

The following figure shows the cluster architecture:

The following describes the parameters:

  • default_cluster
    • default_cluster indicates the name of the current cluster.
    • The current cluster has two shards. Each shard has two replicas, and each replica corresponds to a ClickHouse instance node.
    • internal_replication indicates whether internal replication is performed between replicas. It takes effect when data is inserted into shards through the cluster.

      The default value is true, indicating that data is written to only one replica. (Data is synchronized between replica through replicated tables to ensure data consistency.)

      If this parameter is set to false (not recommended), same data is written to all replicas of the shard. (Data between replicas is not strongly consistent, and full synchronization cannot be ensured.)

  • macros

    macros indicates IDs the shard and replica where the current instance node resides. It can be used to distinguish different replicas.

    For example, the preceding example shows the configuration of the host3 instance. The shard ID of the instance is 2 and the replica ID is 1.

This section describes how to configure sharding and replication. For details about how to synchronize data between replicas in the ClickHouse cluster, see Replication.

Replication

ClickHouse uses ZooKeeper and the ReplicatedMergeTree engine (of Replicated series) to implement replication. Replication uses a multi-master scheme. The INSERT statement can be sent to any replica, and data is replicated to other replicas in the shard asynchronously.

In the following figure, Node 1 and Node 2 correspond to host1 and host2 in Cluster Configuration.

After the ClickHouse cluster is successfully created, three ZooKeeper nodes are created by default. ZooKeeper stores the metadata of the ClickHouse table during replication.

For details about the ZooKeeper node information, see the config.xml file in the ${BIGDATA_HOME}/FusionInsight_ClickHouse_Version number/x_x_ClickHouse instance name/etc directory.

<yandex>
  ...
  <zookeeper>
    <node index="1">
      <host>node-master1lrgj.9bf17e66-e7ed-4f21-9dfc-34575f955ae6.com</host>
      <port>2181</port>
    </node>
    <node index="2">
      <port>2181</port>
      <host>node-master2vocd.9bf17e66-e7ed-4f21-9dfc-34575f955ae6.com</host>
    </node>
    <node index="3">
      <host>node-master3xwmu.9bf17e66-e7ed-4f21-9dfc-34575f955ae6.com</host>
      <port>2181</port>
    </node>
  </zookeeper>
  ...

For details about how to use the cluster after configuration, see Creating a ClickHouse Table.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback