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

下载clickhouse的rpm包

首先创建RPM包所在位置

mkdir -p /opt/software/clickhouse/
cd /opt/software/clickhouse/

下载地址

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

关闭防火墙

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

参数配置

远程访问

  • 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>

注意 : 为什么直接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.
      -->

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

<macros>
<replica>dataqin01</replica>
</macros>

验证集群是否配置成功

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

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

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

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值