ClickHouse集群版部署

==作者:YB-Chi==

[toc]

部署结构

3节点3实例3分片1副本

image

元素讲解

Shard

和es的概念类似,将一份数据分割为多个shard去存储,

Replica

副本这个名词有歧义,官方介绍一个副本就是1份数据,而不是传统的主数据+副本数据的概念.

Layer

和es的cluster.name类似,因为ck可以是多主架构的,所以可以根据不同的layer指定不同的集群类别.

如果是一个整体集群,那么所有node填写相同的一个layer.

安装流程

1
2
3
4
5
6
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://packages.clickhouse.com/rpm/clickhouse.repo
sudo yum install -y clickhouse-server clickhouse-client

sudo /etc/init.d/clickhouse-server start
clickhouse-client # or "clickhouse-client --password" if you set up a password.

tabix参照单机版文档随便找个节点开启

修改配置文件

/etc/clickhouse-server/metrika.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?xml version="1.0"?>
<clickhouse>
<clickhouse_remote_servers>
<ckcluster_3shard_3replica>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>node1</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>node2</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>node3</host>
<port>9000</port>
</replica>
</shard>
</ckcluster_3shard_3replica>
</clickhouse_remote_servers>
<macros>
<layer>ckcluster_3shard_3replica</layer>
<!--根据前面shard的配置,例子中总共3个shard-->
<shard>shard01</shard>
<!--每个节点配置本地主机名即可,或者唯一的数字id-->
<replica>node1</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>
</case>
</clickhouse_compression>
</clickhouse>

其他节点差异化的参数就俩 <shard>shard01</shard> <replica>node1</replica>

config.xml

1
2
<remote_servers incl="clickhouse_remote_servers" />
<include_from>/etc/clickhouse-server/metrika.xml</include_from>

后续

1
2
3
4
5
chown clickhouse:clickhouse /etc/clickhouse-server/metrika.xml
#启动
systemctl start clickhouse-server
#开机自启
systemctl enable clickhouse-server
文章作者: CYBSKY
文章链接: https://cybsky.top/2022/10/27/cyb-mds/database/ClickHouse/ClickHouse集群版部署/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 CYBSKY