探索ClickHouse——安装和测试

这篇具有很好参考价值的文章主要介绍了探索ClickHouse——安装和测试。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。


我们在Ubuntu 20 Server版虚拟机上对ClickHouse进行探索。

安装

检测环境

grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported"

SSE 4.2 supported

可以看到我们的环境支持编译版本的。如果不支持的环境可以考虑通过源码编译安装。

安装

sudo apt-get install -y apt-transport-https ca-certificates dirmngr
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 8919F6BD2B48D754

echo "deb https://packages.clickhouse.com/deb stable main" | sudo tee /etc/apt/sources.list.d/clickhouse.list
sudo apt-get update

sudo apt-get install -y clickhouse-server clickhouse-client

结束时会让输入default用户的密码。

Enter password for default user:

Password for default user is saved in file /etc/clickhouse-server/users.d/default-password.xml.
Setting capabilities for clickhouse binary. This is optional.
chown -R clickhouse:clickhouse ‘/etc/clickhouse-server’
ClickHouse has been successfully installed.
Start clickhouse-server with:
sudo clickhouse start
Start clickhouse-client with:
clickhouse-client --password

启动

 sudo clickhouse start

chown -R clickhouse: ‘/var/run/clickhouse-server/’
Will run sudo --preserve-env -u ‘clickhouse’ /usr/bin/clickhouse-server --config-file /etc/clickhouse-server/config.xml --pid-file /var/run/clickhouse-server/clickhouse-server.pid --daemon
Waiting for server to start
Waiting for server to start
Server started

测试

我们以“英国房地产支付价格”中2021年数据为例。

下载

我们把数据下载下来,查看下其数据内容。

wget http://prod1.publicdata.landregistry.gov.uk.s3-website-eu-west-1.amazonaws.com/pp-2021.csv .

分析数据

head -10 pp-2021.csv
"{D22473F5-3802-7B40-E053-6C04A8C0A630}","230000","2021-06-09 00:00","CO13 0PQ","D","N","F","4","","BELLAMY CLOSE","KIRBY CROSS","FRINTON-ON-SEA","TENDRING","ESSEX","A","A"
"{D22473F5-3803-7B40-E053-6C04A8C0A630}","700000","2021-06-25 00:00","IG10 4BS","T","N","F","70","","SMARTS LANE","","LOUGHTON","EPPING FOREST","ESSEX","A","A"
"{D22473F5-3804-7B40-E053-6C04A8C0A630}","625000","2021-06-28 00:00","EN9 1LH","S","N","F","7","","THE COBBINS","","WALTHAM ABBEY","EPPING FOREST","ESSEX","A","A"
"{D22473F5-3805-7B40-E053-6C04A8C0A630}","360000","2021-02-17 00:00","SS9 3AU","S","N","F","117","","FLEMMING AVENUE","","LEIGH-ON-SEA","SOUTHEND-ON-SEA","SOUTHEND-ON-SEA","A","A"
"{D22473F5-3806-7B40-E053-6C04A8C0A630}","345000","2021-06-25 00:00","SS15 6BG","S","N","F","2","","BROADWATER GREEN","LAINDON","BASILDON","BASILDON","ESSEX","A","A"
"{D22473F5-3807-7B40-E053-6C04A8C0A630}","220000","2021-08-20 00:00","CO7 0HE","S","N","F","133","","CHAPEL ROAD","BRIGHTLINGSEA","COLCHESTER","TENDRING","ESSEX","A","A"
"{D22473F5-3808-7B40-E053-6C04A8C0A630}","362000","2021-06-29 00:00","SS15 4AX","T","N","F","32","","CROUCH STREET","","BASILDON","BASILDON","ESSEX","A","A"
"{D22473F5-3809-7B40-E053-6C04A8C0A630}","300000","2021-06-25 00:00","CM9 6EP","T","N","F","58","","ORCHARD ROAD","","MALDON","MALDON","ESSEX","A","A"
"{D22473F5-380A-7B40-E053-6C04A8C0A630}","300000","2021-06-17 00:00","SS4 3AR","T","N","F","32","","ALLERTON CLOSE","","ROCHFORD","ROCHFORD","ESSEX","A","A"
"{D22473F5-380B-7B40-E053-6C04A8C0A630}","535000","2021-10-22 00:00","SS9 1PZ","T","N","F","113","","LEIGHTON AVENUE","","LEIGH-ON-SEA","SOUTHEND-ON-SEA","SOUTHEND-ON-SEA","A","A"

这些字段具体表意可以参考“英国房地产支付价格”,即

  • uuid_string String,
  • price_string String,
  • time String,
  • postcode String,
  • a String,
  • b String,
  • c String,
  • addr1 String,
  • addr2 String,
  • street String,
  • locality String,
  • town String,
  • district String,
  • county String,
  • d String,
  • e String

放置

默认的用户文件放置位置如如下配置

<user_files_path>/var/lib/clickhouse/user_files/</user_files_path>

切到root用户,将文件放置到上述目录文章来源地址https://www.toymoban.com/news/detail-685572.html

su root
cp pp-2021.csv /var/lib/clickhouse/user_files/
exit

查询

clickhouse-client
SELECT * FROM file('pp-2021.csv', 'CSV', 'uuid_string String, price_string String, time String, postcode String, a String, b String, c String, addr1 String, addr2 String, street String, locality String, town String, district String, county String, d String, e String') LIMIT 10;
SELECT *
FROM file('pp-2021.csv', 'CSV', 'uuid_string String, price_string String, time String, postcode String, a String, b String, c String, addr1 String, addr2 String, street String, locality String, town String, district String, county String, d String, e String')
LIMIT 10

Query id: c08072df-a934-4276-bfbc-68d480409ca1

┌─uuid_string────────────────────────────┬─price_string─┬─time─────────────┬─postcode─┬─a─┬─b─┬─c─┬─addr1─┬─addr2─┬─street───────────┬─locality──────┬─town───────────┬─district────────┬─county──────────┬─d─┬─e─┐
│ {D22473F5-3802-7B40-E053-6C04A8C0A630} │ 230000       │ 2021-06-09 00:00 │ CO13 0PQ │ D │ N │ F │ 4     │       │ BELLAMY CLOSE    │ KIRBY CROSS   │ FRINTON-ON-SEA │ TENDRING        │ ESSEX           │ A │ A │
│ {D22473F5-3803-7B40-E053-6C04A8C0A630} │ 700000       │ 2021-06-25 00:00 │ IG10 4BS │ T │ N │ F │ 70    │       │ SMARTS LANE      │               │ LOUGHTON       │ EPPING FOREST   │ ESSEX           │ A │ A │
│ {D22473F5-3804-7B40-E053-6C04A8C0A630} │ 625000       │ 2021-06-28 00:00 │ EN9 1LH  │ S │ N │ F │ 7     │       │ THE COBBINS      │               │ WALTHAM ABBEY  │ EPPING FOREST   │ ESSEX           │ A │ A │
│ {D22473F5-3805-7B40-E053-6C04A8C0A630} │ 360000       │ 2021-02-17 00:00 │ SS9 3AU  │ S │ N │ F │ 117   │       │ FLEMMING AVENUE  │               │ LEIGH-ON-SEA   │ SOUTHEND-ON-SEA │ SOUTHEND-ON-SEA │ A │ A │
│ {D22473F5-3806-7B40-E053-6C04A8C0A630} │ 345000       │ 2021-06-25 00:00 │ SS15 6BG │ S │ N │ F │ 2     │       │ BROADWATER GREEN │ LAINDON       │ BASILDON       │ BASILDON        │ ESSEX           │ A │ A │
│ {D22473F5-3807-7B40-E053-6C04A8C0A630} │ 220000       │ 2021-08-20 00:00 │ CO7 0HE  │ S │ N │ F │ 133   │       │ CHAPEL ROAD      │ BRIGHTLINGSEA │ COLCHESTER     │ TENDRING        │ ESSEX           │ A │ A │
│ {D22473F5-3808-7B40-E053-6C04A8C0A630} │ 362000       │ 2021-06-29 00:00 │ SS15 4AX │ T │ N │ F │ 32    │       │ CROUCH STREET    │               │ BASILDON       │ BASILDON        │ ESSEX           │ A │ A │
│ {D22473F5-3809-7B40-E053-6C04A8C0A630} │ 300000       │ 2021-06-25 00:00 │ CM9 6EP  │ T │ N │ F │ 58    │       │ ORCHARD ROAD     │               │ MALDON         │ MALDON          │ ESSEX           │ A │ A │
│ {D22473F5-380A-7B40-E053-6C04A8C0A630} │ 300000       │ 2021-06-17 00:00 │ SS4 3AR  │ T │ N │ F │ 32    │       │ ALLERTON CLOSE   │               │ ROCHFORD       │ ROCHFORD        │ ESSEX           │ A │ A │
│ {D22473F5-380B-7B40-E053-6C04A8C0A630} │ 535000       │ 2021-10-22 00:00 │ SS9 1PZ  │ T │ N │ F │ 113   │       │ LEIGHTON AVENUE  │               │ LEIGH-ON-SEA   │ SOUTHEND-ON-SEA │ SOUTHEND-ON-SEA │ A │ A │
└────────────────────────────────────────┴──────────────┴──────────────────┴──────────┴───┴───┴───┴───────┴───────┴──────────────────┴───────────────┴────────────────┴─────────────────┴─────────────────┴───┴───┘

10 rows in set. Elapsed: 0.003 sec. 

参考资料

  • https://clickhouse.com/docs/zh/getting-started/install
  • https://clickhouse.com/docs/zh/getting-started/example-datasets/uk-price-paid
  • https://clickhouse.com/docs/en/sql-reference
  • https://clickhouse.com/docs/en/sql-reference/table-functions/file

到了这里,关于探索ClickHouse——安装和测试的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Ubuntu安装clickhouse数据库

    目录 1、更新包列表  2、运行安装脚本 3、设置密码 4、启动服务 5、测试连接 6、下载官方测试数据         1、下载数据集直接执行以下代码          2、创建数据库         3、创建数据表(1)         4、创建数据表(2)         5、导入数据 7、测试查询  8、远程连接

    2024年02月02日
    浏览(47)
  • 架构探索之路-第一站-clickhouse

    架构, 软件开发中最熟悉不过的名词, 遍布在我们的日常开发工作中, 大到项目整体, 小到功能组件, 想要实现高性能、高扩展、高可用的目标都需要优秀架构理念辅助. 所以本人尝试编写架构系列文章, 去剖析市面上那些经典优秀的开源项目, 学习优秀的架构理念来积累架构设计

    2024年02月05日
    浏览(54)
  • 探索ClickHouse——使用Projection加速查询

    在测试Projection之前,我们需要先创建一张表,并导入大量数据。 我们可以直接使用指令,从URL指向的文件中获取内容并导入表。但是担心网络不稳定,我们先将文件下载下来。 28497127 pp-complete.csv -rw-rw-r-- 1 fangliang fangliang 4982107267 Aug 29 05:13 pp-complete.csv 即这个文件约有2850万行

    2024年02月07日
    浏览(42)
  • 探索ClickHouse——同时支持导入导出功能的文件格式

    在 《探索ClickHouse——安装和测试》中,我们使用clickhouse直接从文件中读取数据。clickhouse支持多种格式文件的导入导出,本节我们对此进行分类介绍。 原始的JSON格式只支持导入,不支持导入。同时支持导入和导出的是其他几种类型: JSONEachRow JSONStringsEachRow JSONCompactEachRow

    2024年02月07日
    浏览(47)
  • 大数据测试-hive、doris、clickhouse、mysql、elasticsearch、kudu、postgresql、sqlserver

    大数据工作要接触很多的数据库和查询引擎 数据库 : 1、 hive :用于跑批,大批量,稳定,缺点:无update。用于数仓 2、 doris db :已更名starrocks。即时查询 可达千亿级别 文档:什么是 StarRocks @ StarRocks_intro @ StarRocks Docs 3、 clickhouse :亿级别 局限性:主表,单表支持能力强,

    2024年02月05日
    浏览(47)
  • (三十六)大数据实战——ClickHouse数据库的部署安装实现

    ClickHouse是俄罗斯的Yandex于2016年开源的列式存储数据库 DBMS ),使用C语言编写,主要用于在线分析处理查询( OLAP ),能够使用SQL查询实时生成分析数据报告。 列式存储 :数据按列进行存储,这使得 ClickHouse 能够高效地处理聚合查询和分析操作; 高性能 :ClickHouse 被设计用

    2024年02月19日
    浏览(40)
  • ClickHouse 与 Amazon S3 结合?一起来探索其中奥秘

    目录 ClickHouse 简介 ClickHouse 与对象存储 ClickHouse 与 S3 结合的三种方法 示例参考架构 小结 参考资料 ClickHouse 简介 ClickHouse 是一种快速的、开源的、用于联机分析(OLAP)的列式数据库管理系统(DBMS),由俄罗斯的Yandex公司开发,于2016年开源。ClickHouse 作为交互式分析领域的后

    2024年02月10日
    浏览(39)
  • 【Clickhouse】ReplaceingMergeTree引擎final实现合并去重探索

    在OLAP实践中,在有数据更新的场景中,比如存储订单数据,我们经常会用到ReplaceingMergeTree引擎来去重数据,以获取数据的最新状态。但是ReplaceingMergeTree引擎实现数据的去重合并的操作是异步的,这样在实际查询的时候,其实是仍然有一部分数据是未进行合并的。为了保证统

    2024年02月08日
    浏览(64)
  • docker安装mysql、clickhouse、oracle等各种数据库汇总

    1:docker 安装mongo数据库并使用 官网:https://www.mongodb.com/docs/manual/ mongo shell教程1:http://c.biancheng.net/mongodb2/connection.html 安装1 :https://www.zhihu.com/question/54602953/answer/3047452434?utm_id=0 安装2:https://www.duidaima.com/Group/Topic/ArchitecturedDesign/9182 使用驱动进行java开发:https://mongodb.github.

    2024年02月10日
    浏览(53)
  • 【超全面】Docker使用:基本安装 + 常用命令 + 安装mysql、redis、clickhouse + 使用数据卷安装 + 制作镜像

    Docker 是一个开源的应用容器引擎,基于 Go 语言 并遵从 Apache2.0 协议开源。 Docker 可以让开发者打包他们的应用以及依赖包到一个轻量级、可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。 容器是完全使用沙箱机制,相互之间不会有任何接口(类似

    2024年02月01日
    浏览(69)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包