全网最细最全OLAP之clickhouse笔记|clickhouse文档|clickhouse揭秘文档(三)--clickhouse单机安装和clickhouse集群安装
程序员文章站
2022-07-06 15:46:53
...
免费**** https://www.51doit.com/ 或者联系博主微信 17710299606
1 单节点安装
1 安装curl工具
yum install -y curl
2 添加clickhouse的yum镜像
curl -s https://packagecloud.io/install/repositories/altinity/clickhouse/script.rpm.sh | sudo bash
3 检查镜像情况
[[email protected] yum.repos.d]# yum list | grep clickhouse
clickhouse-client.x86_64 20.5.4.40-1.el7 @Altinity_clickhouse
clickhouse-common-static.x86_64 20.5.4.40-1.el7 @Altinity_clickhouse
4 安装clickhouse的服务端和客户端
yum install -y clickhouse-server clickhouse-client
5 启动服务daunt
service clickhouse-server start
6 启动交互式客户端
clickhouse-client -m
客户端支持的参数如下:
2 集群安装
clickhouse的集群安装就是在每台机器上安装CH的服务端以及客户端!!所以在每台机器上重复单机安装步骤!
1)修改/etc/clickhouse-server/目录下的config.xml
<listen_host>::</listen_host>
<!-- <listen_host>::1</listen_host> -->
<!-- <listen_host>127.0.0.1</listen_host> -->
2)将修改好的配置文件分发到其他CH节点上
3)在/etc/下创建集群配置文件metrika.xml文件(这个文件需要创建),在CH启动的时候会加载这个配置文件以集群的形式启动CH
metrika.xml文件配置内容
<clickhouse_remote_servers>
<doit_ch_cluster1>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>doit01</host>
<port>9000</port>
</replica>
</shard>
<shard>
<replica>
<internal_replication>true</internal_replication>
<host>doit02</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>doit03</host>
<port>9000</port>
</replica>
</shard>
</doit_ch_cluster1>
</clickhouse_remote_servers>
<zookeeper-servers>
<node index="1">
<host>doit01</host>
<port>2181</port>
</node>
<node index="2">
<host>doit02</host>
<port>2181</port>
</node>
<node index="3">
<host>doit03</host>
<port>2181</port>
</node>
</zookeeper-servers>
<macros>
<replica>doit01</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>
在每台机器上启动CH服务.以集群的形式启动 , 如果想要再以单节点的形式启动那么就删除/etc/下的
metrika.xml文件即可单节点的形式启动!
查看集群配置情况 select * from system.clusters