druid如何用利用tranquity server 向druid发送实时数据


1. 前提条件

   分布式druid系统安装已经完毕,安装过程见

 https://blog.csdn.net/bigtree_3721/article/details/79583008

参考doc: https://github.com/druid-io/tranquility/blob/master/docs/server.md

2. 下载tranquility server

官方下载地址:http://static.druid.io/tranquility/releases/tranquility-distribution-0.8.2.tgz

把 下载好的tar包解压到 /opt/tranquility-distribution-0.8.2

#cd /opt/tranquility-distribution-0.8.2

# vi conf/server.json

内容如下:

  1. {
  2. "dataSources" : {
  3. "mypageviews" : {
  4. "spec" : {
  5. "dataSchema" : {
  6. "dataSource" : "mypageviews",
  7. "parser" : {
  8. "type" : "string",
  9. "parseSpec" : {
  10. "timestampSpec" : {
  11. "format": "auto",
  12. "column": "time"
  13. },
  14. "dimensionsSpec" : {
  15. "dimensions": ["url", "user"]
  16. },
  17. "format" : "json"
  18. }
  19. },
  20. "granularitySpec" : {
  21. "type" : "uniform",
  22. "segmentGranularity" : "hour",
  23. "queryGranularity" : "none"
  24. },
  25. "metricsSpec" : [
  26. {"name": "views", "type": "count"},
  27. {"name": "latencyMs", "type": "doubleSum", "fieldName": "latencyMs"}
  28. ] },
  29. "ioConfig" : {
  30. "type" : "realtime"
  31. },
  32. "tuningConfig" : {
  33. "type" : "realtime",
  34. "maxRowsInMemory" : "100000",
  35. "intermediatePersistPeriod" : "PT1M",
  36. "windowPeriod" : "PT10M",
  37. "basePersistDirectory": "/data/persist"
  38. }
  39. },
  40. "properties" : {
  41. "task.partitions" : "1",
  42. "task.replicants" : "1"
  43. }
  44. }
  45. },
  46. "properties" : {
  47. "zookeeper.connect" : "10.70.27.8:2181,10.70.27.10:2181,10.70.27.12:2181",
  48. "druid.discovery.curator.path" : "/druid/discovery",
  49. "druid.selectors.indexing.serviceName" : "druid/overlord",
  50. "http.port" : "8200",
  51. "http.threads" : "8"
  52. }
  53. }

3. 启动 tranquility

nohup bin/tranquility server -configFile conf/server.json  > ./tranquit.out 2>&1 &

4. 发送 http post 请求到transquitity server

 可以用postman来发送请求:

地址: http://10.70.27.8:8200/v1/post/mypageviews

方法: post

内容:{"time": "2018-04-02T03:15:17Z", "url": "iroot.com/overea", "user": "today2551", "latencyMs":10}

content type: application/json

注意:"time"的值得现查系统,可以在linux用下面的命令获得:

# python -c 'import datetime; print(datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"))'
2018-04-02T11:38:08Z


版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/bigtree_3721/article/details/79793768

1. 前提条件

   分布式druid系统安装已经完毕,安装过程见

 https://blog.csdn.net/bigtree_3721/article/details/79583008

参考doc: https://github.com/druid-io/tranquility/blob/master/docs/server.md

2. 下载tranquility server

官方下载地址:http://static.druid.io/tranquility/releases/tranquility-distribution-0.8.2.tgz

把 下载好的tar包解压到 /opt/tranquility-distribution-0.8.2

#cd /opt/tranquility-distribution-0.8.2

# vi conf/server.json

内容如下:

  1. {
  2. "dataSources" : {
  3. "mypageviews" : {
  4. "spec" : {
  5. "dataSchema" : {
  6. "dataSource" : "mypageviews",
  7. "parser" : {
  8. "type" : "string",
  9. "parseSpec" : {
  10. "timestampSpec" : {
  11. "format": "auto",
  12. "column": "time"
  13. },
  14. "dimensionsSpec" : {
  15. "dimensions": ["url", "user"]
  16. },
  17. "format" : "json"
  18. }
  19. },
  20. "granularitySpec" : {
  21. "type" : "uniform",
  22. "segmentGranularity" : "hour",
  23. "queryGranularity" : "none"
  24. },
  25. "metricsSpec" : [
  26. {"name": "views", "type": "count"},
  27. {"name": "latencyMs", "type": "doubleSum", "fieldName": "latencyMs"}
  28. ] },
  29. "ioConfig" : {
  30. "type" : "realtime"
  31. },
  32. "tuningConfig" : {
  33. "type" : "realtime",
  34. "maxRowsInMemory" : "100000",
  35. "intermediatePersistPeriod" : "PT1M",
  36. "windowPeriod" : "PT10M",
  37. "basePersistDirectory": "/data/persist"
  38. }
  39. },
  40. "properties" : {
  41. "task.partitions" : "1",
  42. "task.replicants" : "1"
  43. }
  44. }
  45. },
  46. "properties" : {
  47. "zookeeper.connect" : "10.70.27.8:2181,10.70.27.10:2181,10.70.27.12:2181",
  48. "druid.discovery.curator.path" : "/druid/discovery",
  49. "druid.selectors.indexing.serviceName" : "druid/overlord",
  50. "http.port" : "8200",
  51. "http.threads" : "8"
  52. }
  53. }

3. 启动 tranquility

nohup bin/tranquility server -configFile conf/server.json  > ./tranquit.out 2>&1 &

4. 发送 http post 请求到transquitity server

 可以用postman来发送请求:

地址: http://10.70.27.8:8200/v1/post/mypageviews

方法: post

内容:{"time": "2018-04-02T03:15:17Z", "url": "iroot.com/overea", "user": "today2551", "latencyMs":10}

content type: application/json

注意:"time"的值得现查系统,可以在linux用下面的命令获得:

# python -c 'import datetime; print(datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"))'
2018-04-02T11:38:08Z


猜你喜欢

转载自blog.csdn.net/wangshuminjava/article/details/80897647