Drill和Hadoop平台、MongoDB上的连接
Drill很大一个特性就是和Hadoop平台的集成,提供了3种方式
(1)直接访问HDFS
(2)访问HIVE
(3)访问HBASE
我使用CDH 5.7的版本,Drill使用1.8, 都使用远程方式连接,需要配置hostname
HDFS
访问方式和访问文件一样,配置也是类似
--hdfs
{
"type": "file",
"enabled": true,
"connection": "hdfs://master:9000/",
"config": null,
"workspaces": {
"root": {
"location": "/yourfolder/",
"writable": true,
"defaultInputFormat": null
}
},
"formats": {
"csv": {
"type": "text",
"extensions": [
"csv"
],
"delimiter": ","
},
"tsv": {
"type": "text",
"extensions": [
"tsv"
],
"delimiter": "\t"
},
"parquet": {
"type": "parquet"
}
}
}
访问方式(注意如果没有表头需要使用column[n]):
SELECT columns[0],CAST(columns[1] AS varchar(20)) FROM hdfs.`/yourfolder/testdata.csv` LIMIT 3;
HIVE
---hive
{
"type": "hive",
"enabled": false,
"configProps": {
"hive.metastore.uris":"thrift://master:9083",
"hive.metastore.sasl.enabled":"false",
"fs.default.name":"hdfs://master:9000/"
}
}
访问方式:
select *from hive.test.testdata LIMIT 30;
注意hive metastore需要启动, 我在测试自行安装的版本就出了一些问题
hive --service metastore
HBASE
HBASE这部分花的时间多了点,自带的jar包有些问题,会报这个错误,
IllegalAccessError: tried to access method com.google.common.base.Stopwatch.()V
使用HBASE Shaded Client 替换即可,下载地址
http://mvnrepository.com/artifact/org.apache.hbase/hbase-shaded-client/1.2.3
问题参考
https://issues.apache.org/jira/browse/HBASE-14126?jql=project%20in%20(HBASE%2C%20DRILL)%20AND%20text%20~%20com.google.common.base.Stopwatch
这个花了我们一天的时间去找,我会有一篇专门博客讲一下这个问题。
配置如下, 注意zookeeper和namenode的host name需要在host文件配置。
--hbase
{
"type": "hbase",
"config": {
"hbase.zookeeper.quorum": "master",
"hbase.zookeeper.property.clientPort": "2181"
},
"size.calculator.enabled": false,
"enabled": true
}
访问方式:
select *from hbase.testdata;
MongoDB
---mongo
{
"type": "mongo",
"connection": "mongodb://master:27017/",
"enabled": false
}
访问方式:
select *from mongo.testdb.testdata LIMIT 30;
说明:
目前发现中文感觉总有点问题,这个需要进一步看了