首页 > 其他分享 >ClickHouse(22)ClickHouse集成HDFS表引擎详细解析

ClickHouse(22)ClickHouse集成HDFS表引擎详细解析

时间:2024-01-27 14:14:27浏览次数:32  
标签:HDFS 22 hdfs 引擎 详细 解析 ClickHouse

HDFS

这个引擎提供了与Apache Hadoop生态系统的集成,允许通过ClickHouse管理HDFS上的数据。这个引擎提供了Hadoop的特定功能。

用法

ENGINE = HDFS(URI, format)

URI 参数是HDFS中整个文件的URI
format 参数指定一种可用的文件格式。执行SELECT查询时,格式必须支持输入,以及执行INSERT查询时,格式必须支持输出.路径部分URI可能包glob通配符。在这种情况下,表将是只读的。

clickhouse支持的format,文件格式:

格式 输入 输出
[TabSeparated]
[TabSeparatedRaw]
[TabSeparatedWithNames]
[TabSeparatedWithNamesAndTypes]
[Template]
[TemplateIgnoreSpaces]
[CSV]
[CSVWithNames]
[CustomSeparated]
[Values]
[Vertical]
[JSON]
[JSONAsString]
[JSONStrings]
[JSONCompact]
[JSONCompactStrings]
[JSONEachRow]
[JSONEachRowWithProgress]
[JSONStringsEachRow]
[JSONStringsEachRowWithProgress]
[JSONCompactEachRow]
[JSONCompactEachRowWithNamesAndTypes]
[JSONCompactStringsEachRow]
[JSONCompactStringsEachRowWithNamesAndTypes]
[TSKV]
[Pretty]
[PrettyCompact]
[PrettyCompactMonoBlock]
[PrettyNoEscapes]
[PrettySpace]
[Protobuf]
[ProtobufSingle]
[Avro]
[AvroConfluent]
[Parquet]
[Arrow]
[ArrowStream]
[ORC]
[RowBinary]
[RowBinaryWithNamesAndTypes]
[Native]
[Null]
[XML]
[CapnProto]
[LineAsString]
[Regexp]
[RawBLOB]

示例:

1. 设置 hdfs_engine_table 表:

CREATE TABLE hdfs_engine_table (name String, value UInt32) ENGINE=HDFS('hdfs://hdfs1:9000/other_storage', 'TSV')

2. 填充文件:

INSERT INTO hdfs_engine_table VALUES ('one', 1), ('two', 2), ('three', 3)

3. 查询数据:

SELECT * FROM hdfs_engine_table LIMIT 2
┌─name─┬─value─┐
│ one  │     1 │
│ two  │     2 │
└──────┴───────┘

实施细节

  • 读取和写入可以并行
  • 不支持:
    • ALTERSELECT...SAMPLE 操作。
    • 索引。
    • 复制。

路径中的通配符

多个路径组件可以具有 globs。 对于正在处理的文件应该存在并匹配到整个路径模式。 文件列表的确定是在 SELECT 的时候进行(而不是在 CREATE 的时候)。

  • * — 替代任何数量的任何字符,除了 / 以及空字符串。
  • ? — 代替任何单个字符.
  • {some_string,another_string,yet_another_one} — 替代任何字符串 'some_string', 'another_string', 'yet_another_one'.
  • {N..M} — 替换 N 到 M 范围内的任何数字,包括两个边界的值.

示例

  1. 假设我们在 HDFS 上有几个 TSV 格式的文件,文件的 URI 如下:
  • ‘hdfs://hdfs1:9000/some_dir/some_file_1’
  • ‘hdfs://hdfs1:9000/some_dir/some_file_2’
  • ‘hdfs://hdfs1:9000/some_dir/some_file_3’
  • ‘hdfs://hdfs1:9000/another_dir/some_file_1’
  • ‘hdfs://hdfs1:9000/another_dir/some_file_2’
  • ‘hdfs://hdfs1:9000/another_dir/some_file_3’
  1. 有几种方法可以创建由所有六个文件组成的表:
CREATE TABLE table_with_range (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_{1..3}', 'TSV')

另一种方式:

CREATE TABLE table_with_question_mark (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/some_file_?', 'TSV')

表由两个目录中的所有文件组成(所有文件都应满足query中描述的格式和模式):

CREATE TABLE table_with_asterisk (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/{some,another}_dir/*', 'TSV')

注意:

如果文件列表包含带有前导零的数字范围,请单独使用带有大括号的构造或使用 `?`.

示例

创建具有名为文件的表 file000, file001, … , file999:

CREARE TABLE big_table (name String, value UInt32) ENGINE = HDFS('hdfs://hdfs1:9000/big_dir/file{0..9}{0..9}{0..9}', 'CSV')

配置

与 GraphiteMergeTree 类似,HDFS 引擎支持使用 ClickHouse 配置文件进行扩展配置。有两个配置键可以使用:全局 (hdfs) 和用户级别 (hdfs_*)。首先全局配置生效,然后用户级别配置生效 (如果用户级别配置存在) 。

  <!-- HDFS 引擎类型的全局配置选项 -->
  <hdfs>
    <hadoop_kerberos_keytab>/tmp/keytab/clickhouse.keytab</hadoop_kerberos_keytab>
    <hadoop_kerberos_principal>[email protected]</hadoop_kerberos_principal>
    <hadoop_security_authentication>kerberos</hadoop_security_authentication>
  </hdfs>

  <!-- 用户 "root" 的指定配置 -->
  <hdfs_root>
    <hadoop_kerberos_principal>[email protected]</hadoop_kerberos_principal>
  </hdfs_root>

可选配置选项及其默认值的列表

libhdfs3 支持的

| 参数 | 默认值 |
| rpc_client_connect_tcpnodelay | true |
| dfs_client_read_shortcircuit | true |
| output_replace-datanode-on-failure | true |
| input_notretry-another-node | false |
| input_localread_mappedfile | true |
| dfs_client_use_legacy_blockreader_local | false |
| rpc_client_ping_interval | 10 * 1000 |
| rpc_client_connect_timeout | 600 * 1000 |
| rpc_client_read_timeout | 3600 * 1000 |
| rpc_client_write_timeout | 3600 * 1000 |
| rpc_client_socekt_linger_timeout | -1 |
| rpc_client_connect_retry | 10 |
| rpc_client_timeout | 3600 * 1000 |
| dfs_default_replica | 3 |
| input_connect_timeout | 600 * 1000 |
| input_read_timeout | 3600 * 1000 |
| input_write_timeout | 3600 * 1000 |
| input_localread_default_buffersize | 1 * 1024 * 1024 |
| dfs_prefetchsize | 10 |
| input_read_getblockinfo_retry | 3 |
| input_localread_blockinfo_cachesize | 1000 |
| input_read_max_retry | 60 |
| output_default_chunksize | 512 |
| output_default_packetsize | 64 * 1024 |
| output_default_write_retry | 10 |
| output_connect_timeout | 600 * 1000 |
| output_read_timeout | 3600 * 1000 |
| output_write_timeout | 3600 * 1000 |
| output_close_timeout | 3600 * 1000 |
| output_packetpool_size | 1024 |
| output_heeartbeat_interval | 10 * 1000 |
| dfs_client_failover_max_attempts | 15 |
| dfs_client_read_shortcircuit_streams_cache_size | 256 |
| dfs_client_socketcache_expiryMsec | 3000 |
| dfs_client_socketcache_capacity | 16 |
| dfs_default_blocksize | 64 * 1024 * 1024 |
| dfs_default_uri | "hdfs://localhost:9000" |
| hadoop_security_authentication | "simple" |
| hadoop_security_kerberos_ticket_cache_path | "" |
| dfs_client_log_severity | "INFO" |
| dfs_domain_socket_path | "" |

HDFS 配置参考 也许会解释一些参数的含义.

ClickHouse 额外的配置

| 参数 | 默认值 |
|hadoop_kerberos_keytab | "" |
|hadoop_kerberos_principal | "" |
|hadoop_kerberos_kinit_command | kinit |

限制

  • hadoop_security_kerberos_ticket_cache_path 只能在全局配置, 不能指定用户

Kerberos 支持

如果 hadoop_security_authentication 参数的值为 'kerberos' ,ClickHouse 将通过 Kerberos 设施进行认证。
注意,由于 libhdfs3 的限制,只支持老式的方法。数据节点的安全通信无法由SASL保证 ( HADOOP_SECURE_DN_USER 是这种安全方法的一个可靠指标)。

如果指定了hadoop_kerberos_keytab, hadoop_kerberos_principal或者hadoop_kerberos_kinit_command,将会调用kinit工具.在此情况下,hadoop_kerberos_keytab和hadoop_kerberos_principal参数是必须配置的.kinit工具和 krb5 配置文件是必要的.

虚拟列

  • _path — 文件路径.
  • _file — 文件名.

资料分享

ClickHouse经典中文文档分享

系列文章

clickhouse系列文章

知乎系列文章

标签:HDFS,22,hdfs,引擎,详细,解析,ClickHouse
From: https://www.cnblogs.com/the-pig-of-zf/p/17991368

相关文章

  • 在ubuntu22上使用C++20
    Linux系统ubuntu22.04安装最新版的gcc13.1.0编译器,支持c++20、23_gcc-13.1.0.tar.gz下载-CSDN博客ubantu20安装多个版本的gcc/gc++编译器_ubuntu安装多个gcc-CSDN博客5步在Ubuntu22上使用C++201.安装build-essentialsudoaptinstallbuild-essential安装完检查/us......
  • [西湖论剑 2022]web部分题解(更新中ing
    [西湖论剑2022]NodeMagicalLogin环境!启动!(ノへ ̄、)这么一看好像弱口令啊,(不过西湖论剑题目怎么会这么简单,当时真的傻),那就bp抓包试一下(这里就不展示了,因为是展示自己思路,这里就写了一下当时的NC思路,其实是不对的┭┮﹏┭┮)不是BP弱口令?那好吧,我们先看一下源码,比赛的时候是给了源......
  • P9805 [POI2022~2023R1] ply
    1st思路贪心当遇到左括号深度加一,可如果当前深度大于$H$时深度减二,并且$ans$加一。相当于进行一次翻转操作。当遇到右括号深度减一,当深度小于零时深度加二,并且$ans$加一。code#include<bits/stdc++.h>usingnamespacestd;strings;intk,n=0,m=0,ans=0;intmain......
  • 春秋云境CVE-2022-30887
    一进来看到一个登录页面,随便找个字典进行爆破,结果发现不行 没有头绪去看了会wp。点击页面底部的MayuriK,翻到页面最底部,随便点一个 会弹出邮箱号 密码为mayurik,也许是名字?  在addmedicine中发现可以上传文件的地方,尝试上传一句话木马 上传成功 找到木......
  • 春秋云境CVE-2022-32991
    进来后看到如下页面,先试试能不能注册点击register,成功注册 登录后,发现url有?q=1,尝试闭合,没发现注入点 打开burp抓包,发现有挺多get参数,一个一个尝试 试到eid的时候,发现存在字符注入点,而且有回显,可以用union联合查询,确定有5列 eid=5b141b8009cf0'+union+select+1,......
  • Ubuntu 22.04.1 LTS 安装 supervisor
    Supervisor是用Python开发的一套通用的进程管理程序,能将一个普通的命令行进程变为后台daemon,并监控进程状态,异常退出时能自动重启。它是通过fork/exec的方式把这些被管理的进程当作supervisor的子进程来启动,这样只要在supervisor的配置文件中,把要管理的进程的可执行文件的路径写进......
  • 22
    importtorchimporttorch.nnasnnimporttorch.nn.functionalasFfromeinopsimportrearrange#Borrowedfrom''Improvingimagerestorationbyrevisitingglobalinformationaggregation''#-------------------------------------------......
  • 国产车灯芯片9V 12V 24V 48V 60V 90V 外围简单-H5022L
    车灯芯片是用于控制车灯光系统的集成电路,其主要功能是管理车辆的照明系统。以下是车灯芯片的一些优点:节能环保:一些先进的车灯芯片采用高效能的LED技术,相比传统照明系统更为节能,有助于减少车辆能耗,降低碳排放。多功能性:车灯芯片能够支持多种灯光模式,包括近光、远光、转向灯等,实现多......
  • 和鲸CEO范向伟入选2022年上海市东方英才计划创业项目领军创业人才
    1月17日下午,徐家汇环交大人工智能科创街区建设推进会在中银慧谷举行。本次活动由徐家汇街道党工委、办事处,徐汇区科学技术委员会和上海交大科技园有限公司共同主办,旨在进一步加强科技创新对区域高质量发展的支撑引领作用,围绕环交大特色产业内核,全面推进徐家汇环交大人工智能科创街......
  • Ubuntu22.04 上使用 C 语言实现简易聊天室程序
    Linux程序设计课程作业,在此记录下我的实现过程和思路,如有错误或不足,欢迎指正!代码:https://github.com/Tangsmallrong/Linux_network_program/1.需求设计并实现一个简单的聊天室程序,实现如下功能:用户界面:实现基于终端的字符界面,支持用户管理,包括用户名和密码的注册与登录。......