Environment to prepare

1. Host planning

Host System OS The hardware configuration
10.196.17.57 Centos 7.8.2003 32 core, 64 g
10.196.17.58 Centos 7.8.2003 32 core, 64 g
10.196.17.60 Centos 7.8.2003 32 core, 64 g

Ii. Required Software packages

  • Clickhouse – server – 21.7.6.39 TGZ

  • Clickhouse – common – static – 21.7.6.39 TGZ

  • Clickhouse – the client – 21.7.6.39 TGZ

  • Zookeeper – 3.4.9. Tar. Gz

    • We already have a cluster. Please refer to the section of deploying ZooKeeper in kafka cluster construction.

The deployment of

You are advised to use the YUM installation mode

Clickhouse- Install

A, decompression

TGZ tar -zxvf clickhouse-common-static-21.7.6.39.tgz tar -zxvf clickhouse-server-21.7.6.39.tgz tar -zxvf Clickhouse - the client - 21.7.6.39 TGZCopy the code

Second, the installation

Sudo clickhouse - the client - 21.7.6.39 / install/doinst. Sh sudo clickhouse - common - static - 21.7.6.39 / install/doinst sh sudo Clickhouse - server - 21.7.6.39 / install/doinst. ShCopy the code

Three, configuration,

1, modify,/etc/clickhouse-server/config.xmlfile
[root@hadoop-prod-datanode5 clickhouse-server]# vim /etc/clickhouse-server/config.xml<listen_host>::</listen_host> </listen_host> </listen_host>Copy the code
2. Search for this comment

If element has ‘incl’ attribute, then for it’s value will be used corresponding substitution from another file.By default, path to file with substitutions is /etc/metrika.xml. It could be changed in config in ‘include_from’ element.Values for substitutions are specified in /yandex/name_of_substitution elements in that file.

As you can see, Clickhouse uses the /etc/metrika.xml configuration file by default, or you can use the default path. If you like me want to customize the configuration file path, please add the following configuration

<include_from>/etc/clickhouse-server/config.d/metrika.xml</include_from>
Copy the code
3, new/etc/clickhouse-server/config.d/metrika.xmlFile, paste the following content:
<yandex>
<! -- CK cluster node -->
<remote_servers>
    <test_ck_cluster>
        <! - shard 1 -- - >
        <shard>
            <weight>1</weight>
            <internal_replication>false</internal_replication>
            <replica>
                <host>10.196.17.57</host>
                <port>9999</port>
                <user>default</user>
                <password></password>
               <compression>true</compression>
            </replica>
            <replica>
                <host>10.196.17.58</host>
                <port>9999</port>
                <user>default</user>
                <password></password>
                <compression>true</compression>
            </replica>
        </shard>
        <! 2 - divided -- -- >
        <shard>
            <weight>1</weight>
            <internal_replication>false</internal_replication>
            <replica>
                <host>10.196.17.60</host>
                <port>9999</port>
                <user>default</user>
                <password></password>
               <compression>true</compression>
            </replica>
            <replica>
                <host>10.196.17.58</host>
                <port>9999</port>
                <user>default</user>
                <password></password>
                <compression>true</compression>
            </replica>
        </shard>
		<! 3 - divided -- -- >
        <shard>
            <weight>1</weight>
            <internal_replication>false</internal_replication>
            <replica>
                <host>10.196.17.60</host>
                <port>9999</port>
                <user>default</user>
                <password></password>
               <compression>true</compression>
            </replica>
            <replica>
                <host>10.196.17.58</host>
                <port>9999</port>
                <user>default</user>
                <password></password>
                <compression>true</compression>
            </replica>
        </shard>
    </test_ck_cluster>
</remote_servers>

<! -- ZooKeeper configuration -->
<zookeeper>
    <node index="1">
        <host>10.196.17.26</host>
        <port>2181</port>
    </node>
    <node index="2">
        <host>10.196.17.27</host>
        <port>2181</port>
    </node>
    <node index="3">
        <host>10.196.17.28</host>
        <port>2181</port>
    </node>
</zookeeper>

<macros>
    <replica>10.196.17.58</replica> <! -- Host name of current node -->
</macros>

<networks>
    <ip>: : / 0</ip>
</networks>

<! -- Compression related configuration -->
<clickhouse_compression>
    <case>
        <min_part_size>10000000000</min_part_size>
        <min_part_size_ratio>0.01</min_part_size_ratio>
        <method>lz4</method> <! Lz4 compression algorithm is faster than ZSTD compression and takes more disk
    </case>
</clickhouse_compression>
</yandex>
Copy the code

The configuration files of the three nodes are different

<macros>
    <replica>10.196.17.58</replica> <! -- Host name of current node -->
</macros>
Copy the code

If you are not sure what many of the configuration options do, open the ClickhouseDocument document to read about them.

If this page does not find the configuration you want to search for, please copy the configuration to the search box

4. How to properly plan your shards and replicas

Refer to zhihu blogger’s article

zhuanlan.zhihu.com/p/161242274

CSDN

Blog.csdn.net/luomingkui1…

Test the cluster

[root@hadoop-prod-datanode4 clickhouse-server]# clickhouse-client --port 9999
Copy the code

I changed the port number. If you use the default 9000, you can click House-client directly and enter it

select * from system.clusters;
Copy the code

After the speech

I write blog is generally save for their own, at the same time to teach people to fish than to teach people to fish, do not cooperate with the official document to write things, after the new version has changed, you need to go to Baidu corresponding document to keep trying wrong (domestic blog CSDN CV used to open five, there are three identical, wrong are wrong of the same). This defeats the purpose of my blog. Well, I wish you all the best

What time is it? Be happy ~