Apache Drill学习

简介: 简介Apache Drill is a low latency distributed query engine for large-scale datasets, including structured and semi-structured/nested data.

简介

Apache Drill is a low latency distributed query engine for large-scale datasets, including structured and semi-structured/nested data.

官网:http://drill.apache.org/

Apache Drill的用途:Drill是SQL查询引擎,可以构建在几乎所有的NoSQL数据库或文件系统(如:Hive, HDFS, mongo db, Amazon S3等)上,用来加速查询,比如,我们所熟知的Hive,用于在hdfs进行类SQL查询,但是利用Hive的速度比较慢,因此可以利用Drill一类的查询引擎加速查询,用于分布式大数据的实时查询等场景。

架构



drill 通过 Storage plugin interface 即插件的形式实现在不同的数据源上构建查询引擎。

安装,分为嵌入模式与分布模式。

这里介绍linux下嵌入模式的安装:

嵌入模式无需做相关配置,较简便,首先要安装JDK 7;

进入到待安装目录,打开shell;

下载安装包,运行以下命令中其中一条:

wget http://getdrill.org/drill/download/apache-drill-1.1.0.tar.gz

curl -o apache-drill-1.1.0.tar.gz http://getdrill.org/drill/download/apache-drill-1.1.0.tar.gz

下载文件到待安装目录后(或下载后移动至安装目录);

解压缩安装包,执行命令tar -xvzf <.tar.gz file name>

解压缩后,进入目录,此处解压过后的目录为apache-drill-1.1.0,执行命令 bin/drill,如图


此时可能会报错,显示内存不足,这里可以在子目录conf中修改drill-env.sh文件中的默认内存分配设置即可,默认是4G,对于一般家用机器,必然会报错。

即启动嵌入模式drill。

上图中最后一行表明drill已启动,可以开始执行查询,最后一行命令提示符的含义为,0表示连接数,jdbc表示连接类型,zk=local表示使用ZooKeeper本地节点。

退出命令 !quit

drill web访问接口,在浏览器输入 http://<IP address or host name>:8047 即可,访问效果如图:



以上我们安装好了drill工具,但是并未将其与我们的特定数据源关联,以下我们进行相关配置,使其可以对具体数据执行查询。

1. 内存配置,如上,修改,在drill-env.sh中修改参数  XX:MaxDirectMemorySize 即可。

2. 配置多用户设置

3. 配置用户权限与角色

4. 。。。待续


连接数据源

dril连接数据源,通过存储插件形式,这样增加了灵活性,对于不同的数据源,通过插件实现多数据源的兼容,drill可以连接数据库,文件,分布式文件系统,hive metastore等。

可以通过三种方式指定配置存储插件配置:

(1) 通过查询中的FROM语句

(2) 在查询语句前使用USE命令

(3) 在启动drill时指定

Web配置方式

可以在 http://<IP address>:8047/storage 查看和配置存储插件,存在以下选项,

cp连接jar file

dfs连接本地文件系统或任何分布式文件系统,如hadoop,amazon s3等

hbase连接Hbase

hive连接hive metastore

mongo连接MongoDB

点击进入update选项,可以配置数据格式等选项,

可以输入存储插件名字创建新的存储插件,如图


dfs插件配置示例,如图


drill插件可配置属性介绍

Attribute Example Values Required Description
"type" "file"
"hbase"
"hive"
"mongo"
yes A valid storage plugin type name.
"enabled" true
false
yes State of the storage plugin.
"connection" "classpath:///"
"file:///"
"mongodb://localhost:27017/"
"hdfs://"
implementation-dependent The type of distributed file system, such as HDFS, Amazon S3, or files in your file system, and an address/path name.
"workspaces" null
"logs"
no One or more unique workspace names. If a workspace name is used more than once, only the last definition is effective.
"workspaces". . . "location" "location": "/Users/johndoe/mydata"
"location": "/tmp"
no Full path to a directory on the file system.
"workspaces". . . "writable" true
false
no One or more unique workspace names. If defined more than once, the last workspace name overrides the others.
"workspaces". . . "defaultInputFormat" null
"parquet"
"csv"
"json"
no Format for reading data, regardless of extension. Default = "parquet"
"formats" "psv"
"csv"
"tsv"
"parquet"
"json"
"avro"
"maprdb" *
yes One or more valid file formats for reading. Drill implicitly detects formats of some files based on extension or bits of data in the file; others require configuration.
"formats" . . . "type" "text"
"parquet"
"json"
"maprdb" *
yes Format type. You can define two formats, csv and psv, as type "Text", but having different delimiters.
formats . . . "extensions" ["csv"] format-dependent File name extensions that Drill can read.
"formats" . . . "delimiter" "\t"
","
format-dependent Sequence of one or more characters that serve as a record separator in a delimited text file, such as CSV. Use a 4-digit hex code syntax \uXXXX for a non-printable delimiter.
"formats" . . . "quote" """ no A single character that starts/ends a value in a delimited text file.
"formats" . . . "escape" "`" no A single character that escapes a quotation mark inside a value.
"formats" . . . "comment" "#" no The line decoration that starts a comment line in the delimited text file.
"formats" . . . "skipFirstLine" true no To include or omit the header when reading a delimited text file. Set to true to avoid reading headers as data.

也可以通过Drill Rest API进行插件配置,使用POST方式传递名字和配置两个属性,例如

curl -X POST -/json" -d '{"name":"myplugin", "config": {"type": "file", "enabled": false, "connection": "file:///", "workspaces": { "root": { "location": "/", "writable": false, "defaultInputFormat": null}}, "formats": null}}' https://localhost:8047/storage/myplugin.json
上面命令创建一个名为myplugin的插件,用于查询本地文件系统根目录的未知文件类型。

介绍连接hive的配置,首先确保hive metastore服务启动,hive.metastore.urishive --service metastore

进入Drill Web接口,进入Store选项卡, http://<IP address>:8047/storage

点击hive旁的update选项,进行配置,如图


进入配置界面,在默认内容上添加如下,




目录
相关文章
|
1月前
|
SQL 运维 API
Apache Flink 学习教程----持续更新
Apache Flink 学习教程----持续更新
250 0
|
1月前
|
分布式计算 Java 大数据
IO流【Java对象的序列化和反序列化、File类在IO中的作用、装饰器模式构建IO流体系、Apache commons-io工具包的使用】(四)-全面详解(学习总结---从入门到深化)
IO流【Java对象的序列化和反序列化、File类在IO中的作用、装饰器模式构建IO流体系、Apache commons-io工具包的使用】(四)-全面详解(学习总结---从入门到深化)
64 0
|
1月前
|
存储 NoSQL 数据处理
Apache Paimon流式湖仓学习交流群成立
Apache Paimon流式湖仓学习交流群成立
183 2
|
安全 API Apache
Apache服务深入学习篇(详细介绍)
Apache服务深入学习篇(详细介绍)
541 0
Apache服务深入学习篇(详细介绍)
|
缓存 网络协议 关系型数据库
学习http+Apache
学习http+Apache
129 0
|
存储 运维 供应链
为什么要学习 Apache Flink| 学习笔记
快速学习为什么要学习 Apache Flink。
324 0
为什么要学习 Apache Flink| 学习笔记
|
云安全 安全 druid
Apache Log4j2 远程代码执行漏洞学习
通过Apache Log4j2远程代码执行漏洞学习jndi等知识
|
Apache 数据库 Hbase
Apache Drill关联查询
1.配置数据源 可查考:Apache Drill 常用Plugins配置 2.同库关联查询 a).创建HBase表 create 'hbase_entry_index','cf1' create 'hbase_entry_second','cf1' b).
1472 0
|
SQL Java 数据库连接
Apache Drill 常用Plugins配置
1.kafka { "type":"kafka", "kafkaConsumerProps":{ "bootstrap.servers":"hostname1:9092,hostname2:9092,hostname3:9092", "group.
1999 0
|
SQL 分布式数据库 Apache
Apache Phoenix学习记录(SQL on HBase)
1 使用概述 Phoenix是基于HBase的SQL中间件产品,由Salesforce.com公司开源并托管于Github上。对于熟悉关系型数据库的开发人员来说,通过Phoenix可以像使用MySQL等关系型数据库一样使用HBase中的数据表。
3477 0

推荐镜像

更多