Elasticsearch7.3.2学习笔记

如何管理索引的生命周期?

答:
方法一:

  1. 新建policy
  2. 新建template & 关联policy ( "index.lifecycle.name": "datastream_policy")
  3. 创建索引—走模板—应用策略

方法二:

  1. 索引已经存在,模板已经存在
  2. 修改模板关联policy
  3. 通过模板创建的新索引将应用该policy

方法三:

  1. 索引已经存在
  2. 直接对索引加policy,立即生效
    这时,policy的各个phase的min_age都会被比较,然后哪个匹配上了,就执行哪些action
PUT mylogs-pre-ilm*/_settings 
{
  "index": {
    "lifecycle": {
      "name": "mylogs_policy_existing"
    }
  }
}
如何关联ILM policy到具体的索引?

答:
一、可以关联到模板,在rollover使用该模板创建新的索引时,应用该policy,
二、在单独创建索引时,在settings中进行配置
1:新建模板

PUT _template/datastream_template
{
  "index_patterns": [“datastream-demo*"],                 
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 1,
    "index.lifecycle.name": “xxxx",      
    "index.lifecycle.rollover_alias": “datastream-demo”,
  }
}

##匹配全部的datastream-*的索引
2:这个时候不要配置滚动策略,只针对当前索引就行了,因为滚动后产生的索引不会继承这个lifecycle的属性

PUT test-index
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 1,
    "index.lifecycle.name": "my_policy"
  }
}

——————————————————————————————
ES Policy的phases & actions

1.index的phases都有哪几种?

答:
四种,hot(一直被写入的),warm(只读的),cold(不写入了,查询也很慢了),delete(不再需要可以删除的)

  1. hot:The index is actively being written to
  2. warm:The index is generally not being written to, but is still queried
  3. cold:The index is no longer being updated and is seldom queried. The information still needs to be searchable, but it’s okay if those queries are slower.
  4. delete:The index is no longer needed and can safely be deleted
2.Policy的参数

min_age: 从索引创建到现在经过的时间,如果发生了滚动,那就是从滚动到现在的时间
(时间检查的配置:indices.lifecycle.poll_interval=0默认,时间单位:
d-Days,h-Hours,m-Minutes,s-Seconds,ms-Milliseconds,micros-Microseconds,nanos-Nanoseconds)
actions:https://www.elastic.co/guide/en/elasticsearch/reference/7.4/_actions.html

——————————————————————————————
Metricbeat采集数据,采用自定义的Template,并配置日期、大小滚动和自动删除

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值