默认端口:
coordinator http://localhost:8081
overlord http://localhost:8090/console.html
broker 8082
(1) druid datasource配置保存7天的数据
详见http://druid.io/docs/latest/operations/rule-configuration.html
https://groups.google.com/forum/#!searchin/druid-user/rules/druid-user/ve9hb1K6RV4/qcPGRynH3F8J
druid 默认保存所有数据,如果只需要保存7天,那么可以加两个rules,一个loadByPeriod,一个dropForever。
保存rules文件:
$ cat save7day
[
{
"period":"P7D",
"type":"loadByPeriod"
},
{
"type":"dropForever"
}
]
然后写一个提交给coordinator的脚本:
$ cat submmit_rules.sh
#!/bin/sh
curl -X 'POST' -H 'Content-Type:application/json' -d @save7day localhost:8081/druid/coordinator/v1/rules/$1
执行sh submmit_rules.sh datasource
查看rules脚本:
$ cat get_rules.sh
#!/bin/sh
curl -X 'GET' -H 'Content-Type:application/json' localhost:8081/druid/coordinator/v1/rules
当然rules也可以在coordinator页面上设置。
(2) 提交/kill task
提交task的脚本:
$ cat submmit_task.sh
#!/bin/sh
curl -X 'POST' -H 'Content-Type:application/json' -d @$1 localhost:8090/druid/indexer/v1/task
提交task:sh submmit_task.sh realtime_task.json
kill task的脚本:
$ cat kill_task.sh
#!/bin/sh
curl -X 'POST' http://localhost:8090/druid/indexer/v1/task/$1/shutdown
kill task:sh submmit_task.sh taskid
taskid在overlord console上面可以看到
task kill了后需要重新提交时,要么改taskid或者从数据库里面吧task信息删除。
delete from druid_tasks where id = 'taskid';
select * from druid_tasks; 查看数据库里面的task信息
Help in understanding query routing to Historical Node from Broker
https://groups.google.com/forum/#!topic/druid-development/4X7ekXByDPs
https://github.com/druid-io/druid-io.github.io/blob/master/docs/0.7.3/Tutorial:-The-Druid-Cluster.md
CREATE DATABASE druid DEFAULT CHARACTER SET utf8;
grant all privileges on druid.* to 'druid'@'%' IDENTIFIED BY 'diurd';
GRANT ALL ON druid.* TO 'druid'@'localhost' IDENTIFIED BY 'diurd';
flush privileges;
select 普通 filter json:
{
"queryType": "select",
"dataSource": "log",
"dimensions":[],
"metrics":[],
"granularity": "all",
"filter": { "type": "selector", "dimension": "id", "value": "225420" },
"intervals": [
"2013-01-01/2023-01-02"
],
"pagingSpec":{"pagingIdentifiers": {}, "threshold":50}
}
select 正则filter json:
{
"queryType": "select",
"dataSource": "log",
"dimensions":[],
"metrics":[],
"granularity": "all",
"filter": {"type": "regex", "dimension": "src", "pattern": "/tmp/*"},
"intervals": [
"2013-01-01/2023-01-02"
],
"pagingSpec":{"pagingIdentifiers": {}, "threshold":50}
}
select 多个字段条件filter json:
{
"queryType": "select",
"dataSource": "log",
"dimensions":[],
"metrics":[],
"granularity": "all",
"filter": { "type": "and", "fields": [{"type": "selector", "dimension": "cmd", "value": "getfileinfo"}, {"type": "selector", "dimension": "ip", "value": "host1"}, {"type": "selector", "dimension": "proto", "value": "rpc"}] },
"intervals": [
"2013-01-01/2023-01-02"
],
"pagingSpec":{"pagingIdentifiers": {}, "threshold":50}
}