其他分享
首页 > 其他分享> > clickhouse集群搭建

clickhouse集群搭建

作者:互联网

clickhouse集群搭建

搭建前准备
配置好防火墙以及搭建好zookeeper,这里就不做搭建,可自行查找攻略
首先取消打开文件数限制,然后重启不然不生效

[root@node02 ~]#  vim /etc/security/limits.conf
* soft nofile 65536 
* hard nofile 65536 
* soft nproc 131072 
* hard nproc 131072

 安装依赖,rpm离线安装需要此依赖

[root@node02 ~]#  yum install -y libtool
[root@node02 ~]#  yum install -y *unixODBC*

yum安装
# yum 安装 server 以及 client
yum install -y clickhouse-server clickhouse-client

# 查看是否安装完成
 yum list installed 'clickhouse*'
 
 # 通过 clickhouse service 来启动,停止,clickhouse
service clickhouse-server start | stop | status | restart |

#进入client
clickhouse-client

集群搭建
集群搭建和单节点是差不多的,就是编写配置文件就可,首先在其他节点上安装好clickhouse,然后执行下面的步骤
# 1. 修改config.xml配置文件
vim /etc/clickhouse-server/config.xml
# 进入编辑后  /<listen_host> 回车,找到这个位置,这个配置是用于,允许IP4和IP6源主机远程访问
     <listen_host>::</listen_host>
    <!-- Same for hosts with disabled ipv6: -->
    <!-- <listen_host>0.0.0.0</listen_host> -->
# 将注释的内容给打开即可, 注意每台节点都要更改

# 然后进入到/etc目录下创建metrika.xml文件即可
vim metrika.xml内容,我这里是四台节点,配置文件是这样的,以后的文章中会记录clickhouse的一些调优内容

<yandex>
# 集群配置
<clickhouse_remote_servers>
    <perftest_4shards_1replicas>
        <shard>
             <internal_replication>true</internal_replication>
            <replica>
                <host>node01</host>
                <port>9000</port>
            </replica>
        </shard>
        <shard>
            <replica>
                <internal_replication>true</internal_replication>
                <host>node02</host>
                <port>9000</port>
            </replica>
        </shard>
        <shard>
            <internal_replication>true</internal_replication>
            <replica>
                <host>node03</host>
                <port>9000</port>
            </replica>
        </shard>
        <shard>
             <internal_replication>true</internal_replication>
            <replica>
                <host>node04</host>
                <port>9000</port>
            </replica>
        </shard>
    </perftest_4shards_1replicas>   
</clickhouse_remote_servers>
# zk配置
<zookeeper-servers>
  <node index="1">
    <host>node01</host>
    <port>2181</port>
  </node>
  <node index="2">
    <host>node02</host>
    <port>2181</port>
  </node>
  <node index="3">
    <host>node03</host>
    <port>2181</port>
  </node>
  <node index="4">
    <host>node04</host>
    <port>2181</port>
  </node>
</zookeeper-servers>
# 这个位置需要根据不同的节点来更改
<macros>
    <replica>node02</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>

然后将metrika.xml文件分发到其他的节点,然后停止之前启动clickhouse,然后每台节点启动服务,对没看错,不需要在做什么事情了,他会自动读取这个文件,启动就行了

#每个节点启动查看是否启动
ps -aux | grep clickhouse-server

# 如过启动失败可以去查看log ,log位置
/var/log/clickhouse-server

通过clickhouse-client进入集群
查看集群信息
select * from system.clusters;

标签:node02,xml,server,集群,节点,clickhouse,搭建
来源: https://www.cnblogs.com/banger/p/15965605.html