环境准备
一、主机规划
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 |
二、所需软件包
-
zookeeper-3.4.9.tar.gz
- 我司集群已拥有,可以参考历史博客 kafka集群搭建 中部署zookeeper的环节。
部署
推荐使用yum安装方式,此处按解压安装方式部署
教程参考官文:Clickhouse-install
一、解压
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
复制代码
二、安装
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
复制代码
三、配置
1、修改/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>
复制代码
2、搜索此段注释
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.
可以发现Clickhouse默认使用/etc/metrika.xml配置文件,用默认路径也可以,如果你跟我一样希望自定义配置文件路径,请新增如下配置
<include_from>/etc/clickhouse-server/config.d/metrika.xml</include_from>
复制代码
3、新增/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>
复制代码
三个节点配置文件区别
<macros>
<replica>10.196.17.58</replica> <!--当前节点主机名-->
</macros>
复制代码
如果你不清楚很多配置选项是做什么的,请打开ClickhouseDocument文档翻阅相关内容。
如果此页面没有找到你想搜寻的配置,请复制配置到搜索框中搜索
4、如何合理规划自己的分片以及副本
参考知乎博主文章
CSDN
五、测试集群
[root@hadoop-prod-datanode4 clickhouse-server]# clickhouse-client --port 9999
复制代码
我是因为修改了端口号,如果你使用默认9000,那么直接clickhouse-client
即可,进入后输入
select * from system.clusters;
复制代码
后言
我写blog一般都是存底留给自己看,同时授人以鱼不如授人以渔,不配合官方文档写出的东西,以后新版本有变更,你就需要去百度对应的文档去不停试错了(国内博客点名CSDN CV惯了,打开五个,有三个雷同,错都错的一致)。这违背了我写blog的初衷。那就最后祝大家心想事成喽
现在几点?开心一点~
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END