下载clickhouse的rpm包
首先创建RPM包所在位置
mkdir -p /opt/software/clickhouse/
cd /opt/software/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集群配置完成。