Keep an eye on modules

Note: We need to deploy ClickHouse on each node for details on ClickHouse Installation deployment

To configure ClickHouse clusters, you only need to modify Zookeeper storage and add nodes.

Node information


The host IP
ck1 10.10.0.1
ck2 10.10.0.2
ck3 10.10.0.3

Configuration Zookeeper


Add the following configuration information to the /etc/clickhouse-server/config.xml file

<zookeeper>
    <node index="1">
        <host>zk1</host>
        <port>2181</port>
    </node>
    <node index="2">
        <host>zk2</host>
        <port>2181</port>
    </node>
    <node index="3">
        <host>zk3</host>
        <port>2181</port>
    </node>
</zookeeper>
Copy the code

The modified configuration file is used to configure the Zookeeper connection information. The index value of each node cannot be repeated

Be sure to add it to the Yandex node

Configure the ClickHouse cluster


Configuring the ClickHouse cluster node requires configuring the remote_Servers node

Add the following configuration information to the /etc/clickhouse-server/config.xml file

<remote_servers>
    <ck_cluster>
        <shard>
            <weight>1</weight>
            <internal_replication>true</internal_replication>
            <replica>
                <host>ck1</host>
                <port>9000</port>
            </replica>
            <replica>
                <host>ck2</host>
                <port>9000</port>
            </replica>
        </shard>
        <shard>
            <weight>1</weight>
            <internal_replication>true</internal_replication>
            <replica>
                <host>ck2</host>
                <port>9000</port>
            </replica>
            <replica>
                <host>ck3</host>
                <port>9000</port>
            </replica>
        </shard>
        <shard>
            <weight>1</weight>
            <internal_replication>true</internal_replication>
            <replica>
                <host>ck3</host>
                <port>9000</port>
            </replica>
            <replica>
                <host>ck1</host>
                <port>9000</port>
            </replica>
        </shard>
    </ck_cluster>
</remote_servers>
Copy the code
  • ck_clusterThe cluster identifier, which can be customized, is required when creating Distributed tables (with a Distributed engine).
  • weightThe write weight value of each shard. When data is written, there is a high probability that data will fall into the shard with a high weight value. Set all values to 1.
  • internal_replicationWhether to enable internal replication, that is, data is written to only one copy and synchronization of other copies is performed asynchronously by replication tables and ZooKeeper.

What we do in shard shards is we set up circular shards so that we can make sure that one of the nodes that we copy will work if it goes down

The configuration is distributed to all nodes where ClickHouse is deployed for service restart

Our ClickHouse cluster is now complete!