欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

clickhouse-3-集群安装

程序员文章站 2022-07-13 10:18:55
...

1 集群节点信息

10.23.241.139 pda1
10.23.241.212 pda2
10.23.241.213 pda3

2 搭建zookeeper集群

3 三个节点均安装单机版clickhouse以一个为例

3.1 安装

(1)Clickhouse 仅支持 Linux 操作系统,且机器 CPU 必须支持 SSE 4.2 指令集。
#cat /proc/cpuinfo
clickhouse-3-集群安装(2)第三方机构 Altinity 提供了完整的 rpm 包,支持在 Centos 下安装。
网址 https://packagecloud.io/Altinity/clickhouse 。
以下 4 个 rpm 包即可:
clickhouse-3-集群安装clickhouse-client :包含 clickhouse 客户端交互工具
clickhouse-common:包含 clickhouse 服务端执行脚本
clickhouse-server :包含 clickhouse 服务端配置文件
下载
clickhouse-client-20.5.4.40-1.el7.x86_64.rpm
clickhouse-common-static-20.5.4.40-1.el7.x86_64.rpm
clickhouse-server-20.5.4.40-1.el7.x86_64.rpm
clickhouse-server-common-20.5.4.40-1.el7.x86_64.rpm
(3)安装
#rpm -ivh *.rpm
clickhouse-3-集群安装安装后主要目录分布如下表:
/etc/clickhouse-server :clickhouse 服务端配置文件目录
/etc/clickhouse-client :clickhouse 客户端配置文件目录
/var/lib/clickhouse :clickhouse 默认数据目录
/var/log/clickhouse-server :clickhouse 默认日志目录
/etc/init.d/clickhouse-server :clickhouse 服务端启动脚本

3.2 启动与验证

(1)安装完成后,需要手动启动服务:
#systemctl status clickhouse-server查看
#systemctl start clickhouse-server
(2)进入 Clickhouse 客户端交互界面:
#clickhouse-client
clickhouse-3-集群安装查看数据库
clickhouse-3-集群安装或者
#clickhouse-client --host pda1 --port 9000

4 集群部署

以一个节点为例配置

4.1 配置/etc/metrika.xml

vi /etc/metrika.xml

<yandex>
<clickhouse_remote_servers>
<perftest_3shards_1replicas>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>pda1</host>
<port>9000</port>
</replica>
</shard>
<shard>
<replica>
<internal_replication>true</internal_replication>
<host>pda2</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>pda3</host>
<port>9000</port>
</replica>
</shard>
</perftest_3shards_1replicas>
</clickhouse_remote_servers>

<!--zookeeper相关配置-->
<zookeeper-servers>
<node index="1">
<host>pda1</host>
<port>2181</port>
</node>
<node index="2">
<host>pda2</host>
<port>2181</port>
</node>
<node index="3">
<host>pda3</host>
<port>2181</port>
</node>
</zookeeper-servers>
<!-- 其中大部分配置一样,以下的配置根据节点的IP/域名具体配置 -->
<macros>
<replica>pda1</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>

注意:为什么直接vim /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到其他两个节点并配置。

4.2 每个节点都启动clickhouse的服务

systemctl restart clickhouse-server
在每个节点都启动clickhouse的服务,和单节点启动一样,当出现无误后,查看clickhouse的log文件,如果出现以下信息,就基本没有问题

在每个节点启动clickhouse客户端,和单节点启动完全一样,查询集群信息
select * from system.clusters;
clickhouse-3-集群安装

相关标签: 数据库