CentOS Stream 9 搭建三节点Clickhouse集群

发布于:2025-02-11 ⋅ 阅读:(24) ⋅ 点赞:(0)

安装前准备

修改配置

vim /etc/clickhouse-server/config.xml

修改主机名

<interserver_http_host>主机名</interserver_http_host>

在这里插入图片描述

自定义集群名称

<!-- 修改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

<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集群配置

<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服务

systemctl start clickhouse-server

查看clickhouse服务状态

systemctl status clickhouse-server

在这里插入图片描述

集群验证

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

select * from system.clusters;

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

在这里插入图片描述


网站公告

今日签到

点亮在社区的每一天
去签到