Clickhouse集群部署文档

环境准备

1、主机规划

Host System OS 硬件配置
10.196.17.57 Centos 7.8.2003 32Core,64G
10.196.17.58 Centos 7.8.2003 32Core,64G
10.196.17.60 Centos 7.8.2003 32Core,64G

2、所需软件包

部署

推荐使用yum安装方式,此处按解压安装方式部署vim

教程参考官文:Clickhouse-installbash

1、解压

tar -zxvf clickhouse-common-static-21.7.6.39.tgz

tar -zxvf clickhouse-server-21.7.6.39.tgz

tar -zxvf clickhouse-client-21.7.6.39.tgz
复制代码

2、安装

sudo clickhouse-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.sh
复制代码

3、配置

一、修改/etc/clickhouse-server/config.xml文件
[root@hadoop-prod-datanode5 clickhouse-server]# vim /etc/clickhouse-server/config.xml

因为我这边9000端口号被其余服务占用,故把端口号更改成9999
<tcp_port>9999</tcp_port>

放开该配置
<listen_host>::</listen_host>
复制代码
二、搜索此段注释

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.markdown

能够发现Clickhouse默认使用/etc/metrika.xml配置文件,用默认路径也能够,若是你跟我同样但愿自定义配置文件路径,请新增以下配置app

<include_from>/etc/clickhouse-server/config.d/metrika.xml</include_from>
复制代码
三、新增/etc/clickhouse-server/config.d/metrika.xml文件,黏贴以下内容:
<yandex>
<!--ck集群节点-->
<remote_servers>
    <test_ck_cluster>
        <!--分片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-->
        <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-->
        <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相关配置-->
<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> <!--当前节点主机名-->
</macros>

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

<!--压缩相关配置-->
<clickhouse_compression>
    <case>
        <min_part_size>10000000000</min_part_size>
        <min_part_size_ratio>0.01</min_part_size_ratio>
        <method>lz4</method> <!--压缩算法lz4压缩比zstd快, 更占磁盘-->
    </case>
</clickhouse_compression>
</yandex>
复制代码

三个节点配置文件区别tcp

<macros>
    <replica>10.196.17.58</replica> <!--当前节点主机名-->
</macros>
复制代码

若是你不清楚不少配置选项是作什么的,请打开ClickhouseDocument文档翻阅相关内容。oop

若是此页面没有找到你想搜寻的配置,请复制配置到搜索框中搜索

image.png

四、如何合理规划本身的分片以及副本

参考知乎博主文章

zhuanlan.zhihu.com/p/161242274

CSDN

blog.csdn.net/luomingkui1…

5、测试集群

[root@hadoop-prod-datanode4 clickhouse-server]# clickhouse-client --port 9999
复制代码

我是由于修改了端口号,若是你使用默认9000,那么直接clickhouse-client便可,进入后输入

select * from system.clusters;
复制代码

image.png

后言

我写blog通常都是存底留给本身看,同时授人以鱼不如授人以渔,不配合官方文档写出的东西,之后新版本有变动,你就须要去百度对应的文档去不停试错了(国内博客点名CSDN CV惯了,打开五个,有三个雷同,错都错的一致)。这违背了我写blog的初衷。那就最后祝你们心想事成喽

如今几点?开心一点~

相关文章
相关标签/搜索