clickhouse的安装和使用(单机+集群)

本文详细介绍了ClickHouse的安装过程,包括CentOS系统的配置调整,以及单机和分布式模式的安装步骤。还讲解了ClickHouse的数据类型,如整型、浮点型、字符串等,并介绍了Table引擎如TinyLog、Memory、MergeTree及其特性和使用场景。此外,文章还涵盖了基本的SQL语法,如CREATE TABLE和INSERT INTO等。
摘要由CSDN通过智能技术生成

什么是clickhous

ClickHouse 是俄罗斯的Yandex于2016年开源的列式存储数据库(DBMS),主要用于在线分析处理查询(OLAP),能够使用SQL查询实时生成分析数据报告。

安装前的准备

以CentOS6.8为例

1. CentOS取消打开文件数限制
在/etc/security/limits.conf、/etc/security/limits.d/90-nproc.conf这2个文件的末尾加入一下内容:

  • soft nofile 65536
  • hard nofile 65536
  • soft nproc 131072
  • hard nproc 131072
    重启生效 用ulimit –n 或者ulimit –a查看设置结果
    用ulimit –n 或者ulimit –a查看设置结果
[root@hadoop102 ~]# ulimit -n
65536

2. CentOS取消取消SELINU
修改/etc/selinux/config中的SELINUX=disabled后重启

vim /etc/selinux/config
SELINUX=disabled

3. CentOS关闭防火墙

 service iptables stop 
 service ip6tables stop

4. 安装依赖

   yum install -y libtool
   yum install -y *unixODBC*

安装

1.网址

官网
安装包下载地址

2.单机模式

上传5个文件到Linux中

[root@hadoop102 software]# ls
clickhouse-client-1.1.54236-4.el6.x86_64.rpm      
clickhouse-server-1.1.54236-4.el6.x86_64.rpm
clickhouse-compressor-1.1.54236-4.el6.x86_64.rpm  
clickhouse-server-common-1.1.54236-4.el6.x86_64.rpm
clickhouse-debuginfo-1.1.54236-4.el6.x86_64.rpm

分别安装这5个rpm文件

[root@hadoop102 software]#  rpm -ivh *.rpm 

启动ClickServer
前台启动:

clickhouse-server –config-file=/etc/clickhouse-server/config.xml

后台启动:

nohup clickhouse-server –config-file=/etc/clickhouse-server/config.xml  >null 2>&1 
[1] 2696

使用client连接server

clickhouse-client 

3.分布式安装

准备三台机器,改好主机名之类的,然后执行以上所有步骤
我这里是hadoop102,hadoop103,hadoop104

三台机器修改配置文件config.xml

vim /etc/clickhouse-server/config.xml
把60行左右的三行改为这样
    <listen_host>::</listen_host>
    <!-- <listen_host>::1</listen_host> -->
    <!-- <listen_host>127.0.0.1</listen_host> -->

在三台机器的etc目录下新建metrika.xml文件

vim /etc/metrika.xml
添加如下内容:
<yandex>
<clickhouse_remote_servers>
    <perftest_3shards_1replicas>
        <shard>
             <internal_replication>true</internal_replication>
            <replica>
                <host>hadoop102</host>
                <port>9000</port>
            </replica>
        </shard>
        <shard>
            <replica>
                <internal_replication>true</internal_replication>
                <host>hadoop103</host>
                <port>9000</port>
            </replica>
        </shard>
        <shard>
            <internal_replication>true</internal_replication>
            <replica>
                <host>hadoop104</host>
                <port>9000</port>
            </replica>
        </shard>
    </perftest_3shards_1replicas>
</clickhouse_remote_servers>


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

  <node index="2">
    <host>hadoop103</host>
    <port>2181</port>
  </node>
  <node index="3">
    <host>hadoop104</host>
    <port>2181</port>
  </node>
</zookeeper-servers>

<macros>
    <replica>hadoop102</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>                                                                                                              
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值