没有合适的资源?快使用搜索试试~ 我知道了~
首页大数据资料之ClickHouse.pdf
大数据资料之ClickHouse.pdf
需积分: 50 671 浏览量
更新于2023-03-03
评论
收藏 196KB PDF 举报
ClickHouse概述、安装、数据类型、表引擎、SQL语法。相对比较简洁汇总的一个文档,适合于入门学习整理。
资源详情
资源评论
资源推荐

大数据技术之 ClickHouse
第 1 章 ClickHouse 概述
1.1 什么是 ClickHouse
ClickHouse 是俄罗斯的 Yandex 于 2016 年开源的列式存储数据库( DBMS ),主要
用于在线分析处理查询( OLAP ),能够使用 SQL 查询实时生成分析数据报告。
1.2 什么是列式存储
以下面的表为例:
Id Name Age
1 张三 18
2 李四 22
3 王五 34
采用行式存储时,数据在磁盘上的组织结构为:
1 张三 18 2 李四 22 3 王五 34
好处是想查某个人所有的属性时, 可以通过一次磁盘查找加顺序读取就可以。 但是当想查所
有人的年龄时,需要不停的查找,或者全表扫描才行,遍历的很多数据都是不需要的。
而采用列式存储时,数据在磁盘上的组织结构为:
1 2 3 张三 李四 王五 18 22 34
这时想查所有人的年龄只需把年龄那一列拿出来就可以了

1.3 安装前的准备
1.3.1 CentOS 取消打开文件数限制
在/etc/security/limits.conf 、/etc/security/limits.d/90-nproc.conf 这 2 个文件的末
尾加入一下内容:
[root@hadoop102 software]# vim /etc/security/limits.conf
在文件末尾添加:
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
[root@hadoop102 software]# vim /etc/security/limits.d/90-nproc.conf
在文件末尾添加:
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
重启服务器之后生效,用 ulimit -n 或者 ulimit -a 查看设置结果
[root@hadoop102 ~]# ulimit -n
65536
1.3.2 CentOS 取消 SELINUX
修改 /etc/selinux/config 中的 SELINUX=disabled 后重启
[root@hadoop102 ~]# vim /etc/selinux/config
SELINUX=disabled
1.3.3 关闭防火墙
[root@hadoop102 ~]# service iptables stop
[root@hadoop102 ~]# service ip6tables stop
ip6tables :将 chains 设置为 ACCEPT 策略: filter [ 确定 ]
ip6tables :清除防火墙规则: [确定 ]
:正在卸载模块: [确定 ]
1.3.4 安装依赖
[root@hadoop102 ~]# yum install -y libtool

[root@hadoop102 ~]# yum install -y *unixODBC*
第 2 章 安装
2.1 网址
官网: https://clickhouse.yandex/
下载地址: http://repo.red-soft.biz/repos/clickhouse/stable/el6/
2.2 单机模式
2.2.1 上传 5 个文件到 /opt/software/
[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
2.2.2 分别安装这 5 个 rpm 文件
[root@hadoop102 software]# rpm -ivh *.rpm
Preparing...
########################################### [100%]
1:clickhouse-server-
commo########################################### [ 20%]
2:clickhouse-server
########################################### [ 40%]
3:clickhouse-client
########################################### [ 60%]
4:clickhouse-debuginfo
########################################### [ 80%]
5:clickhouse-compressor
########################################### [100%]
2.2.3 启动 ClickServer
前台启动:
[root@hadoop102 software]# clickhouse-server --config-file=/etc/clickhouse-
server/config.xml

后台启动:
[root@hadoop102 software]# nohup clickhouse-server --config-
file=/etc/clickhouse-server/config.xml >null 2>&1 &
[1] 2696
2.2.4 使用 client 连接 server
[root@hadoop102 software]# clickhouse-client
ClickHouse client version 1.1.54236.
Connecting to localhost:9000.
Connected to ClickHouse server version 1.1.54236.
:)
2.3 分布式集群安装
2.3.1 在 hadoop103 ,hadoop104 上面执行之前的所有步骤
2.3.2 三台机器修改配置文件 config.xml
[root@hadoop102 ~]# vim /etc/clickhouse-server/config.xml
<listen_host>::</listen_host>
<!-- <listen_host>::1</listen_host> -->
<!-- <listen_host>127.0.0.1</listen_host> -->
[root@hadoop103 ~]# vim /etc/clickhouse-server/config.xml
<listen_host>::</listen_host>
<!-- <listen_host>::1</listen_host> -->
<!-- <listen_host>127.0.0.1</listen_host> -->
[root@hadoop104 ~]# vim /etc/clickhouse-server/config.xml
<listen_host>::</listen_host>
<!-- <listen_host>::1</listen_host> -->
<!-- <listen_host>127.0.0.1</listen_host> -->

2.3.3 在三台机器的 etc 目录下新建 metrika.xml 文件
[root@hadoop102 ~]# 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">
剩余22页未读,继续阅读











安全验证
文档复制为VIP权益,开通VIP直接复制

评论0