Quickstart单机测试

http://druid.io/docs/0.10.1/tutorials/quickstart.html

(1)Getting started

下载安装Druid:

curl -O http://static.druid.io/artifacts/releases/druid-0.10.1-bin.tar.gz
tar -xzf druid-0.10.1-bin.tar.gz
cd druid-0.10.1

主要目录:

  • LICENSE - the license files.
  • bin/ - scripts useful for this quickstart.
  • conf/* - template configurations for a clustered setup.
  • conf-quickstart/* - configurations for this quickstart.
  • extensions/* - all Druid extensions.
  • hadoop-dependencies/* - Druid Hadoop dependencies.
  • lib/* - all included software packages for core Druid.
  • quickstart/* - files useful for this quickstart.

(2)Start up Zookeeper

启动ZK

curl http://www.gtlib.gatech.edu/pub/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz -o zookeeper-3.4.6.tar.gz

tar -xzf zookeeper-3.4.6.tar.gz
cd zookeeper-3.4.6
cp conf/zoo_sample.cfg conf/zoo.cfg
./bin/zkServer.sh start

(3)Start up Druid services

启动Druid,Zookeeper running后,返回 druid-0.10.1目录,执行

 bin/init

这会为我们建立目录如log和var,下面在不同的terminal windows中执行不同的进程

java `cat conf-quickstart/druid/historical/jvm.config | xargs` -cp "conf-quickstart/druid/_common:conf-quickstart/druid/historical:lib/*" io.druid.cli.Main server historical
java `cat conf-quickstart/druid/broker/jvm.config | xargs` -cp "conf-quickstart/druid/_common:conf-quickstart/druid/broker:lib/*" io.druid.cli.Main server broker
java `cat conf-quickstart/druid/coordinator/jvm.config | xargs` -cp "conf-quickstart/druid/_common:conf-quickstart/druid/coordinator:lib/*" io.druid.cli.Main server coordinator
java `cat conf-quickstart/druid/overlord/jvm.config | xargs` -cp "conf-quickstart/druid/_common:conf-quickstart/druid/overlord:lib/*" io.druid.cli.Main server overlord
java `cat conf-quickstart/druid/middleManager/jvm.config | xargs` -cp "conf-quickstart/druid/_common:conf-quickstart/druid/middleManager:lib/*" io.druid.cli.Main server middleManager

  

如果需要CTRL-C 来结束(这里不需要)

如果需要重启,需要删掉var目录,然后重启bin/init

摄入数据

在druid-0.10.1目录下执行

curl -X 'POST' -H 'Content-Type:application/json' -d @quickstart/wikiticker-index.json localhost:8090/druid/indexer/v1/task

返回
{"task":"index_hadoop_wikiticker_2017-11-26T12:57:40.055Z"}

ingestion task console: http://localhost:8090/console.html

 
image

coordinator console http://localhost:8081/#/.

 
image
 
image
 

(4)查询数据

执行

curl -L -H'Content-Type: application/json' -XPOST --data-binary @quickstart/wikiticker-top-pages.json http://localhost:8082/druid/v2/?pretty

返回

[html] view plaincopy

<embed id="ZeroClipboardMovie_1" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16" height="16" name="ZeroClipboardMovie_1" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=1&width=16&height=16" wmode="transparent" >

  1. {"task":"index_hadoop_wikiticker_2017-11-18T16:07:55.681Z"}localhost:druid-0.10.-data-binary @quickstart/wikiticker-top-pages.json http://localhost:8082/druid/v2/?pretty
  2. [ {
  3. "timestamp" : "2015-09-12T00:46:58.771Z",
  4. "result" : [ {
  5. "edits" : 33,
  6. "page" : "Wikipedia:Vandalismusmeldung"
  7. }, {
  8. "edits" : 28,
  9. "page" : "User:Cyde/List of candidates for speedy deletion/Subpage"
  10. }, {
  11. "edits" : 27,
  12. "page" : "Jeremy Corbyn"
  13. }, {
  14. "edits" : 21,
  15. "page" : "Wikipedia:Administrators' noticeboard/Incidents"
  16. }, {
  17. "edits" : 20,
  18. "page" : "Flavia Pennetta"
  19. }, {
  20. "edits" : 18,
  21. "page" : "Total Drama Presents: The Ridonculous Race"
  22. }, {
  23. "edits" : 18,
  24. "page" : "User talk:Dudeperson176123"
  25. }, {
  26. "edits" : 18,
  27. "page" : "Wikipédia:Le Bistro/12 septembre 2015"
  28. }, {
  29. "edits" : 17,
  30. "page" : "Wikipedia:In the news/Candidates"
  31. }, {
  32. "edits" : 17,
  33. "page" : "Wikipedia:Requests for page protection"
  34. }, {
  35. "edits" : 16,
  36. "page" : "Utente:Giulio Mainardi/Sandbox"
  37. }, {
  38. "edits" : 16,
  39. "page" : "Wikipedia:Administrator intervention against vandalism"
  40. }, {
  41. "edits" : 15,
  42. "page" : "Anthony Martial"
  43. }, {
  44. "edits" : 13,
  45. "page" : "Template talk:Connected contributor"
  46. }, {
  47. "edits" : 12,
  48. "page" : "Chronologie de la Lorraine"
  49. }, {
  50. "edits" : 12,
  51. "page" : "Wikipedia:Files for deletion/2015 September 12"
  52. }, {
  53. "edits" : 12,
  54. "page" : "Гомосексуальный образ жизни"
  55. }, {
  56. "edits" : 11,
  57. "page" : "Constructive vote of no confidence"
  58. }, {
  59. "edits" : 11,
  60. "page" : "Homo naledi"
  61. }, {
  62. "edits" : 11,
  63. "page" : "Kim Davis (county clerk)"
  64. }, {
  65. "edits" : 11,
  66. "page" : "Vorlage:Revert-Statistik"
  67. }, {
  68. "edits" : 11,
  69. "page" : "Конституция Японской империи"
  70. }, {
  71. "edits" : 10,
  72. "page" : "The Naked Brothers Band (TV series)"
  73. }, {
  74. "edits" : 10,
  75. "page" : "User talk:Buster40004"
  76. }, {
  77. "edits" : 10,
  78. "page" : "User:Valmir144/sandbox"
  79. } ]

================================

数据加载方法

Loading Data

http://druid.io/docs/0.10.1/tutorials/ingestion.html
两种形式streaming (real-time) file-based (batch)
【1】HDFS文件
http://druid.io/docs/0.10.1/ingestion/batch-ingestion.html
【2】Kafka, Storm, Spark Streaming
利用Tranquility客户端 http://druid.io/docs/0.10.1/ingestion/stream-ingestion.html#stream-push

文件加载简单入门

Files-based
【1】加载本地磁盘文件:http://druid.io/docs/0.10.1/tutorials/tutorial-batch.html
【2】Streams-based
push data over HTTP:http://druid.io/docs/0.10.1/tutorials/tutorial-streams.html

【3】Kafka-based tutorial:http://druid.io/docs/0.10.1/tutorials/tutorial-kafka.html

例子1-加载本地磁盘文件

Loading from Files-Load your own batch data
【1】按照单机版下载并启动
http://druid.io/docs/0.10.1/tutorials/quickstart.html
【2】写ingestion规则
参考下载包中的 quickstart/wikiticker-index.json
要点:
(1)标识dataset,dataSource中dataSchema
(2)标识dataset的位置,inputSpec中的paths,多个文件用逗号分隔
(3)标识timestamp,timestampSpec的column
(4)标识dimensions ,dimensionsSpec的imensions(
(5)标识metrics,metricsSpec
(6)ranges,granularitySpec的intervals
如果数据无时间可以按照"2000-01-01T00:00:00.000Z"形式标识每一行
文件支持TSV, CSV, and JSON ,不支持嵌套JSON
JSON数据形式如下:
pageviews.json文件内容
{"time": "2015-09-01T00:00:00Z", "url": "/foo/bar", "user": "alice", "latencyMs": 32}
{"time": "2015-09-01T01:00:00Z", "url": "/", "user": "bob", "latencyMs": 11}
{"time": "2015-09-01T01:30:00Z", "url": "/foo/bar", "user": "bob", "latencyMs": 45}
主要保证每一行数据没有newline符号
如按下面写规则json,my-index-task.json
"dataSource": "pageviews"
"inputSpec": {
"type": "static",
"paths": "pageviews.json"
}
"timestampSpec": {
"format": "auto",
"column": "time"
}
"dimensionsSpec": {
"dimensions": ["url", "user"]
}
"metricsSpec": [
{"name": "views", "type": "count"},
{"name": "latencyMs", "type": "doubleSum", "fieldName": "latencyMs"}
]
"granularitySpec": {
"type": "uniform",
"segmentGranularity": "day",
"queryGranularity": "none",
"intervals": ["2015-09-01/2015-09-02"]
}
【3】为了保障indexing task可以读到pageviews.json文件内容
(1)本地执行(不配置连接hadoop),将pageviews.json文件放在Druid root目录
(2)若连接hadoop,修改inputSpec中的paths
【4】执行
curl -X 'POST' -H 'Content-Type:application/json' -d @my-index-task.json OVERLORD_IP:8090/druid/indexer/v1/task
若本地执行用下面
curl -X 'POST' -H 'Content-Type:application/json' -d @my-index-task.json localhost:8090/druid/indexer/v1/task=
通过http://OVERLORD_IP:8090/druid/indexer/v1/task 查看indexing的进度
【4】查询数据
数据将在1到2分钟后可用,通过Coordinator console http://localhost:8081/#/. 查看
【5】查看数据
http://druid.io/docs/0.10.1/querying/querying.html

例子2-消费kafka数据

Tutorial: Load from Kafka
【1】下载启动kafka
curl -O http://www.us.apache.org/dist/kafka/0.9.0.0/kafka_2.11-0.9.0.0.tgz
tar -xzf kafka_2.11-0.9.0.0.tgz
cd kafka_2.11-0.9.0.0
启动Kafka broker
./bin/kafka-server-start.sh config/server.properties
建立Kafka topic命名为metrics
./bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic metrics
【2】发送样例数据
Druid目录生成测试数据bin/generate-example-metrics
启动kafka的producer
./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic metrics
将生成的数据贴到producer的终端中
【3】查询数据

转自 http://blog.csdn.net/hjw199089/article/details/78572034

作者:大诗兄_zl
链接:https://www.jianshu.com/p/03d32119dfdc
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

druid部署的更多相关文章

  1. Druid在有赞的实践

    转载一篇自己在公司博客上的文章 一.Druid介绍 Druid 是 MetaMarket 公司研发,专为海量数据集上的做高性能 OLAP (OnLine Analysis Processing)而设计 ...

  2. OLAP引擎:基于Druid组件进行数据统计分析

    一.Druid概述 1.Druid简介 Druid是一款基于分布式架构的OLAP引擎,支持数据写入.低延时.高性能的数据分析,具有优秀的数据聚合能力与实时查询能力.在大数据分析.实时计算.监控等领域都 ...

  3. Druid.io系列(八):部署

    介绍 前面几个章节对Druid的整体架构做了简单的说明,本文主要描述如何部署Druid的环境 Imply提供了一套完整的部署方式,包括依赖库,Druid,图形化的数据展示页面,SQL查询组件等.本文将 ...

  4. Tomcat部署多个Springboot项目报错 InstanceNotFoundException: com.alibaba.druid:type=DruidDataSourceStat

    在一个tomcat服务器下部署了多个采用阿里druid作为数据连接池,结果启动报错.原因是不能在一个tomcat服务器下不能直接部署多个druid作为数据连接池的项目,需要配置. 解决办法: 在spr ...

  5. Druid 0.17 入门(2)—— 安装与部署

    在Druid快速入门其实已经简单的介绍过最简化配置的单节点部署,本文我们将详细描述Druid的多种部署方式,对于测试开发环境可以选用轻量的单机部署方式,而生产环境我们最好选用集群部署的方式,确保系统的 ...

  6. canal部署启动的时候报错com.alibaba.druid.pool.DruidDataSource - testWhileIdle is true, validationQuery not set

    报错信息:com.alibaba.druid.pool.DruidDataSource - testWhileIdle is true, validationQuery not set 解决方法: 找 ...

  7. Springboot项目引入druid安装部署使用

    一.maven引入依赖,数据库驱动根据项目需求自行引入 <!-- https://mvnrepository.com/artifact/com.alibaba/druid-spring-boot ...

  8. spring boot 部署为jar

    前言 一直在ide中敲代码,使用命令行mvn spring-boot:run或者gradlew bootRun来运行spring boot项目.想来放到prod上面也应该很简单.然而今天试了下,各种问 ...

  9. 数据库连接池:Druid

    转自: http://www.cnblogs.com/windlaughing/p/3287501.html Java连接数据库方法概述 java.sql提供了一些接口和类,用于支持数据库增删改查等相 ...

随机推荐

  1. 深入理解Auto Layout 第一弹

    本文转载至 http://zhangbuhuai.com/2015/07/16/beginning-auto-layout-part-1/ By 张不坏 2015-07-16 更新日期:2015-07 ...

  2. You have tried to change the API from what has been previously approved.

    需要修改frameworks/base/下的代码,请注意 :如果修改了Android原有API的 ,需要update frameworks/base/api/current.txt.否则编译被中断并出 ...

  3. 探求C#.Net中ArrayList与Array的区别

     ArrayList与Array的区别概述     ArrayList 是数组的复杂版本.ArrayList 类提供在大多数 Collections 类中提供但不在 Array 类中提供的一些功能.例 ...

  4. Github for Windows 登录时报代理问题?

    Github for Windows 登录时报如下错误: 不要被它的提示信息误导了. 登录失败,跟代理半毛钱关系都没有. 是 .net framework 组件 的问题. 更新下 .net frame ...

  5. C和C++书籍推荐

    http://bestcbooks.com/recommend/most-influential-book/ http://www.ruanyifeng.com/blog/2011/09/c_prog ...

  6. IMAP命令与分析

    https://www.cnblogs.com/crystalray/p/3304688.html Internet Mail Access Protocol(缩写为IMAP,以前称作交互邮件访问协议 ...

  7. 浅谈P2P、P2C 、O2O 、B2C、B2B、 C2C的区别

    相信有很多人对P2P.P2C .O2O .B2C.B2B. C2C不是很熟悉,甚至是云里雾里,每天看着这些常见又陌生的名词,如果有人跟你说 让你解释它的含义,金融的小伙伴们是不是瞬间石化了,尤其是做淘 ...

  8. Maven Assembly插件介绍

    转自:http://blueram.iteye.com/blog/1684070 已经写得挺好的,就不用重写了. 你是否想要创建一个包含脚本.配置文件以及所有运行时所依赖的元素(jar)Assembl ...

  9. 大规模Elasticsearch集群管理心得

    转载:http://elasticsearch.cn/article/110 ElasticSearch目前在互联网公司主要用于两种应用场景,其一是用于构建业务的搜索功能模块且多是垂直领域的搜索,数据 ...

  10. Notepad++如何关闭最近打开的文件的历史记录功能

    Notepad++是Windows 操作系统下的一套非常有特色的自由软件的纯文字编辑器(许可证:GPL),有完整的中文化接口及支持多国语言编写的 功能(UTF8 技术).它的功能比Windows中的N ...