docker虚拟化容器使用教程(Docker安装ClickHouse并初始化数据测试)
类别:服务器 浏览量:1761
时间:2021-10-07 00:08:11 docker虚拟化容器使用教程
Docker安装ClickHouse并初始化数据测试clickhouse简介
ClickHouse是一个面向列存储的数据库管理系统,可以使用SQL查询实时生成分析数据报告,主要用于OLAP(在线分析处理查询)场景。关于clickhouse原理以及基础知识在以后学习中慢慢总结。
1、Docker安装ClickHouse
docker run -d --name some-clickhouse-server \ -p 8123:8123 -p 9009:9009 -p 9091:9000 \ --ulimit nofile=262144:262144 \ -v /home/clickhouse:/var/lib/clickhouse \ yandex/clickhouse-server
2、下载SSBM工具
1、git clone https://github.com/vadimtk/ssb-dbgen.git 2、cd ssb-dbgen 3、make
3、生成数据
./dbgen -s 100 -T c ./dbgen -s 100 -T p ./dbgen -s 100 -T s ./dbgen -s 100 -T l ./dbgen -s 100 -T d
查看下数据
4、建表
CREATE TABLE default.customer ( C_CUSTKEY UInt32, C_NAME String, C_ADDRESS String, C_CITY LowCardinality(String), C_NATION LowCardinality(String), C_REGION LowCardinality(String), C_PHONE String, C_MKTSEGMENT LowCardinality(String) ) ENGINE = MergeTree ORDER BY (C_CUSTKEY);
CREATE TABLE default.lineorder ( LO_ORDERKEY UInt32, LO_LINENUMBER UInt8, LO_CUSTKEY UInt32, LO_PARTKEY UInt32, LO_SUPPKEY UInt32, LO_ORDERDATE Date, LO_ORDERPRIORITY LowCardinality(String), LO_SHIPPRIORITY UInt8, LO_QUANTITY UInt8, LO_EXTENDEDPRICE UInt32, LO_ORDTOTALPRICE UInt32, LO_DISCOUNT UInt8, LO_REVENUE UInt32, LO_SUPPLYCOST UInt32, LO_TAX UInt8, LO_COMMITDATE Date, LO_SHIPMODE LowCardinality(String) ) ENGINE = MergeTree PARTITION BY toYear(LO_ORDERDATE) ORDER BY (LO_ORDERDATE, LO_ORDERKEY);
CREATE TABLE default.part ( P_PARTKEY UInt32, P_NAME String, P_MFGR LowCardinality(String), P_CATEGORY LowCardinality(String), P_BRAND LowCardinality(String), P_COLOR LowCardinality(String), P_TYPE LowCardinality(String), P_SIZE UInt8, P_CONTAINER LowCardinality(String) ) ENGINE = MergeTree ORDER BY P_PARTKEY;
CREATE TABLE default.supplier ( S_SUPPKEY UInt32, S_NAME String, S_ADDRESS String, S_CITY LowCardinality(String), S_NATION LowCardinality(String), S_REGION LowCardinality(String), S_PHONE String ) ENGINE = MergeTree ORDER BY S_SUPPKEY;
5、导入数据
准备工作:
先把ssb-dbgen(lineorder.tbl,customer.tbl,part.tbl,supplier.tbl)考到clickhouse-server容器里面
clickhouse-client --query "INSERT INTO customer FORMAT CSV" < customer.tbl clickhouse-client --query "INSERT INTO part FORMAT CSV" < part.tbl clickhouse-client --query "INSERT INTO supplier FORMAT CSV" < supplier.tbl clickhouse-client --query "INSERT INTO lineorder FORMAT CSV" < lineorder.tbl
注意:如果此处报错,检查clickhouse的配置(端口是否占用,是否设置用户和密码)
6、测试
编号 | 查询语句SQL | 耗时(ms) |
---|---|---|
Q1 | SELECT SUM(l.LO_EXTENDEDPRICE * l.LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE toYear(l.LO_ORDERDATE) = 1993 AND l.LO_DISCOUNT BETWEEN 1 AND 3 AND l.LO_QUANTITY < 25; | 36 |
Q2 | SELECT SUM(l.LO_EXTENDEDPRICE * l.LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE toYYYYMM(l.LO_ORDERDATE) = 199401 AND l.LO_DISCOUNT BETWEEN 4 AND 6 AND l.LO_QUANTITYBETWEEN 26 AND 35; | 12 |
Q3 | SELECT SUM(l.LO_EXTENDEDPRICE * l.LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE toISOWeek(l.LO_ORDERDATE) = 6 AND toYear(l.LO_ORDERDATE) = 1994 AND l.LO_DISCOUNT BETWEEN 5 AND 7 AND l.LO_QUANTITY BETWEEN 26 AND 35; | 12 |
Q4 | SELECT SUM(l.LO_REVENUE), toYear(l.LO_ORDERDATE) AS year, p.P_BRAND FROM lineorder_flat WHERE p.P_CATEGORY = ‘MFGR#12' AND s.S_REGION = ‘AMERICA' GROUP BY year, p.P_BRAND ORDER BY year, p.P_BRAND; | 16 |
Q5 | SELECT SUM(l.LO_REVENUE), toYear(l.LO_ORDERDATE) AS year, p.P_BRAND FROM lineorder_flat WHERE p.P_BRAND BETWEEN ‘MFGR#2221' AND ‘MFGR#2228' AND s.S_REGION = ‘ASIA' GROUP BY year, p.P_BRAND ORDER BY year, p.P_BRAND; | 21 |
Q6 | SELECT toYear(l.LO_ORDERDATE) AS year, s.S_CITY, p.P_BRAND, SUM(l.LO_REVENUE -l.LO_SUPPLYCOST) AS profit FROM lineorder_flat WHERE s.S_NATION = ‘UNITED STATES' AND (year = 1997 OR year = 1998) AND p.P_CATEGORY = ‘MFGR#14' GROUP BY year, s.S_CITY, p.P_BRAND ORDER BY year, s.S_CITY, p.P_BRAND; | 19 |
官网参考:
https://clickhouse.tech/docs/zh/getting-started/example-datasets/star-schema/#star-schema-benchmark
以上就是Docker创建ClickHouse 并初始化数据测试的详细内容,更多关于Docker的资料请关注开心学习网其它相关文章!
标签:Docker ClickHouse
您可能感兴趣
- docker常用操作(docker常用命令汇总)
- 怎么用docker中的mysql连接数据库(连接docker里面的mysql失败解决方法)
- nginxdocker界面(Docker部署nginx实现过程图文详解)
- spring boot docker部署(docker部署springboot和vue项目的实现步骤)
- docker自动入门教程(Docker Machine深入详解)
- docker容器基础入门认知网络篇(Docker 容器生命周期 架构 以及和VM之间的差异详解)
- docker容器卡死(Docker容器不识别宋体等字体的解决方案)
- docker删除多个镜像命令(Docker 彻底删除私有库镜像的操作)
- django框架教程第100讲(详解Django+Vue+Docker搭建接口测试平台实战)
- docker和golang哪个好(使用Golang玩转Docker API的实践)
- docker装redis(通过Docker部署Redis 6.x集群的方法)
- dockerexec详解(docker中的run/cmd/entrypoint的区别详解)
- 容器之间的通信docker(Docker容器互访的三种方法)
- idea docker使用(最新IDEA快速实现Docker镜像部署运行的过程详解)
- 利用docker容器化开发环境(使用docker搭建sonarqube的方法)
- docker容器里面有java运行环境吗(利用 Docker 构建简单的 java 开发编译环境的方法详解)
- 红色代表什么(红色代表什么情感和含义)
- 高中数学题(高中数学题型总结及解题方法)
- 冰岛旅游攻略(冰岛旅游攻略及花费)
- 为什么现在年轻人越来越喜欢买衣服(为什么现在年轻人越来越喜欢买衣服穿)
- 怎么做好SEO(怎么做好seo内容优化)
- 冬季钓鱼子线用 长 还是 短(冬季钓鱼子线用)
热门推荐
- js字符串常用函数
- python删除列表中的重复元素(Python实现去除列表中重复元素的方法总结7种方法)
- nginx动静分离的原理(Nginx动静分离实现案例代码解析)
- 浅谈Python3中strip()、lstrip()、rstrip()用法详解(浅谈Python3中strip、lstrip、rstrip用法详解)
- dedecms模板如何修改日期(DEDECMS网站文章列表页更新点击次数的问题完美解决)
- 腾讯云查看ftp用户名密码(腾讯云服务器ftp连不上的解决办法)
- 访问云服务器磁盘文件路径(云服务器的磁盘要怎么选择?)
- 如何用python在微信里自动回复(Python实现微信自动好友验证,自动回复,发送群聊链接方法)
- vue路由有几种实现模式(Vue实现路由过渡动效的4种方法)
- sqlserver怎么手动添加数据库表(SQL Server 数据库调整表中列的顺序操作方法及遇到问题)
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9