35

学习 Druid(七):Segment

 4 years ago
source link: https://www.tuicool.com/articles/e2aeQrz
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

更新至 Druid 0.15.1 版本

生命周期

TODO

状态

published

Segment 元数据插入 Metadata Storage,Segment 文件推到 Deep Storage。

Segment 元数据表为 druid.druid_segment,表结构如下:

字段名 类型 描述 id varchar(255) 主键 dataSource varchar(255) 所属 DataSource created_date varchar(255) 创建时间 start varchar(255) 分区开始时间 end varchar(255) 分区结束时间 partitioned boolean 是否分区? version varchar(255) 版本 used boolean 是否使用? payload blob JSON 格式,Segment 元数据

Segment 文件位置由配置项 druid.storage.storageDirectory 决定,目录结构:

segments  
 - DataSource
   - Partition
     - Version
       - Segment File

available

Segment 是否可被查询。

used

Segment 是否可用。是 Segment 元数据表 druid.druid_segment 上的标记位。

删除 DataSource 元数据,将 DataSource 所有 Segment 置为 unused:

curl -X DELETE <DRUID_ROUTER_URI>/druid/coordinator/v1/datasources/<DATA_SOURCE>

将 DataSource 时间范围内所有 Segment 置为 unused:

curl -X POST -H 'Content-Type:application/json' -d '{ "interval" : "2019-10-01T00:00:00.000Z/2019-10-08T00:00:00.000Z" }' <DRUID_ROUTER_URI>/druid/coordinator/v1/datasources/<DATA_SOURCE>/markUnused

彻底删除 Segment 数据,必须先将 Segment 置为 unused,然后启动 Kill 任务删除被置为 unused 的 Segment 在 Metadata Storage 上的元数据和 Deep Storage 上的文件。

结构

TODO

优化

TODO

参考


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK