CentOS Stream 9 搭建三节点Clickhouse集群

安装前准备

修改配置

bash 复制代码
vim /etc/clickhouse-server/config.xml

修改主机名

bash 复制代码
<interserver_http_host>主机名</interserver_http_host>

自定义集群名称

bash 复制代码
<!-- 修改remote_servers中的内容如下 -->
<remote_servers>
    <!-- 可自定义clickhouse集群名 -->
    <ck_cluster>  
        <!-- 数据分片1  -->
        <shard>
            <internal_replication>true</internal_replication>
            <replica>
                <host>192.168.225.135</host><!-- 服务器01的IP -->
                <port>6000</port>   <!-- 注意端口,默认9000 -->
            </replica>
        </shard>
        <!-- 数据分片2  -->
        <shard>
            <internal_replication>true</internal_replication>
            <replica>
                <host>192.168.225.137</host><!-- 服务器02的IP -->
                <port>6000</port>   <!-- 注意端口,默认9000 -->
            </replica>
        </shard>
        <!-- 数据分片3  -->
        <shard>
            <internal_replication>true</internal_replication>
            <replica>
                <host>192.168.225.138</host><!-- 服务器03的IP -->
                <port>6000</port>   <!-- 注意端口,默认9000 -->
            </replica>
        </shard>
    </ck_cluster>
</remote_servers>

修改macros

bash 复制代码
<macros>
    <layer>ck_cluster</layer><!-- 上述配置的集群名称 -->
    <shard>01</shard><!-- 分别为01,02,03 -->
    <replica>10.35.36.176</replica><!-- 服务器03的IP -->
</macros>

注:每个机器shard分别为01,02,03,replica也为对应服务器IP

Zookeeper集群配置

bash 复制代码
<zookeeper>
    <!-- index内容为server.xxx:ip:2888:3888中的xxx -->
    <node index="1">
        <host>192.168.225.135</host>
        <port>2181</port>
    </node>
    <node index="2">
        <host>192.168.225.137</host>
        <port>2181</port>
    </node>
    <node index="3">
        <host>192.168.225.138</host>
        <port>2181</port>
    </node>
</zookeeper>

启动Clickhouse集群

三台机器挨个启动clickhouse服务

bash 复制代码
systemctl start clickhouse-server

查看clickhouse服务状态

bash 复制代码
systemctl status clickhouse-server

集群验证

输入clickhouse-client,然后输入单机部署的时候输入的密码,再输入

bash 复制代码
select * from system.clusters;

出来如下信息即表示集群部署成功

相关推荐
未济2 天前
linux 配置环境变量
linux
傲世仙尊2 天前
目录即文件-Ext文件系统收尾篇
linux·c语言
_艾伦 耶格尔.2 天前
进程间通信
linux
Liuqy-052 天前
Linux IO编程——静态库、动态库
linux
彧azz2 天前
Linux 环境下 Redis 学习总结:数据类型、持久化、锁、事务、主从与缓存问题
linux·redis·笔记·学习·面试
-梅2 天前
linux(8) 软硬链接
linux·运维·服务器
AIgorithmGEEK2 天前
[Linux]线程三部曲(上):一个执行流的诞生——从操作系统一路拆到 pthread_create
linux·线程·pid
琥珀色糖2 天前
SimlpeHttp
linux·服务器
qeen872 天前
【Linux】操作系统之进程介绍(二)
linux·笔记·学习·进程
Zenova EdgeOS2 天前
Linux ss 工业边缘网络分析实战
linux·python·边缘计算·工业网关