欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

clickHouse安装

程序员文章站 2022-07-13 10:20:07
...

单节点安装

1)安装curl工具
yum install -y curl


2)添加clickhouse的yum镜像
curl -s https://packagecloud.io/install/repositories/altinity/clickhouse/script.rpm.sh | sudo bash


3)检查镜像情况
[aaa@qq.com]# 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)启动服务端
service clickhouse-server start


6)启动交互式客户端
clickhouse-client -m

 

常用命令:
show databases ;--展示所有的数据库
select currentDatabase() ;  -- 查看当前正在使用的数据库

 

clickHouse安装

 

集群安装

1,现在每台机器上安装单机服务端

2,修改/etc/clickhouse-server/目录下的config.xml

<listen_host>::</listen_host>
<!-- <listen_host>::1</listen_host> -->
<!-- <listen_host>127.0.0.1</listen_host> -->

修改完后分发到其他节点上

3,在/etc/下创建集群配置文件metrika.xml文件(这个文件需要创建)

 在CH启动的时候会加载这个配置文件以集群的形式启动CH

<clickhouse_remote_servers>
    <linux_ch_cluster1>
        <shard>
             <internal_replication>true</internal_replication>
            <replica>
                <host>linux01</host>
                <port>9000</port>
            </replica>
        </shard>
        <shard>
            <replica>
                <internal_replication>true</internal_replication>
                <host>linux02</host>
                <port>9000</port>
            </replica>
        </shard>
        <shard>
            <internal_replication>true</internal_replication>
            <replica>
                <host>linux03</host>
                <port>9000</port>
            </replica>
        </shard>
    </linux_ch_cluster1>
</clickhouse_remote_servers>


<zookeeper-servers>
  <node index="1">
    <host>linux01</host>
    <port>2181</port>
  </node>

  <node index="2">
    <host>linux02</host>
    <port>2181</port>
  </node>
  <node index="3">
    <host>linux03</host>
    <port>2181</port>
  </node>
</zookeeper-servers>

<macros>
    <replica>linux01</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>

创建后并分配到其他节点上

4,启动

在每台机器上启动CH服务.以集群的形式启动 ,
如果想要再以单节点的形式启动那么就删除/etc/下的metrika.xml文件即可单节点的形式启动

5,查看CH的集群情况

select * from system.clusters

clickHouse安装

相关标签: ClickHouse