当前位置:   article > 正文

clickhouse集群搭建【三节点为例】_clockhouse部署

clockhouse部署

下载clickhouse的rpm包

首先创建RPM包所在位置

mkdir -p /opt/software/clickhouse/
cd /opt/software/clickhouse/
  • 1
  • 2

下载地址

clickhouse安装包下载链接

按照顺序安装

rpm -ivh clickhouse-server-common-19.3.6-1.el7.x86_64.rpm
rpm -ivh clickhouse-common-static-19.3.6-1.el7.x86_64.rpm
rpm -ivh clickhouse-server-19.3.6-1.el7.x86_64.rpm
rpm -ivh clickhouse-test-19.3.6-1.el7.x86_64.rpm
rpm -ivh clickhouse-client-19.3.6-1.el7.x86_64.rpm
  • 1
  • 2
  • 3
  • 4
  • 5

关闭防火墙

systemctl stop firewalld   //停止firewall
systemctl disable firewalld  //精致firewall开机启动
  • 1
  • 2

参数配置

远程访问

  • vi /etc/clickhouse-server/config.xml
    修改服务器的配置文件/etc/clickhouse-server/config.xml,找到这个代码快listen specified host,放开注释即可,修改之后的内容如下:
    在这里插入图片描述

内存限制设置

  • vi /etc/clickhouse-server/users.xml
    在这里插入图片描述

数据目录

  • vi /etc/clickhouse-server/config.xml
    在这里插入图片描述

集群部署

三个节点全部按照上面的知道部署单节点成功后开始配置部署集群需要的配置

首先以一个节点为配置

<?xml version="1.0"?>
<yandex>
<clickhouse_remote_servers>
<perftest_3shards_1replicas>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>dataqin01</host>
<port>9000</port>
</replica>
</shard>
<shard>
<replica>
<internal_replication>true</internal_replication>
<host>dataqin02</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>dataqin03</host>
<port>9000</port>
</replica>
</shard>
</perftest_3shards_1replicas>
</clickhouse_remote_servers>

<!--zookeeper相关配置-->
<zookeeper-servers>
<node index="1">
<host>dataqin01</host>
<port>2182</port>
</node>
<node index="2">
<host>dataqin02</host>
<port>2182</port>
</node>
<node index="3">
<host>dataqin03</host>
<port>2182</port>
</node>
</zookeeper-servers>

<macros>
<replica>dataqin03</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>

</yandex>
  • 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
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61

注意 : 为什么直接vi /etc/metrika.xml 一个新文件,这里很难去理解,有点莫名其妙,其实如果仔细看过clickhouse的配置文件 /etc/clickhouse-server/config.xml就能明白,有那么一段被注释的配置说明:

<!-- 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.
      -->
  • 1
  • 2
  • 3
  • 4

配置一个节点完成之后,将/etc/metrika.xml文件scp到其他两个节点并配置

<macros>
<replica>dataqin01</replica>
</macros>
  • 1
  • 2
  • 3

验证集群是否配置成功

在每个节点上启动clickhouse客户端,和单节点启动完全一样

  • 启动clickhouse各个节点:/etc/init.d/clickhouse-server start
  • 客户端访问:clickhouse-client –m
  • 查询节点信息:select * from system.clusters; (三个节点都会如下图所示)
    在这里插入图片描述
  • 关闭服务:/etc/init.d/clickhouse-server start

上述内容完成,则clickhouse集群配置完成。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/246426
推荐阅读
相关标签
  

闽ICP备14008679号