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的初衷。那就最後祝你們心想事成嘍

如今幾點?開心一點~

相關文章
相關標籤/搜索