简体   繁体   English

elasticsearch 模板不更改索引 ILM

[英]elasticsearch template doesn't change index ILM

in my elasticsearch, I will receive daily index with format like dstack-prod_dcbs-.在我的 elasticsearch 中,我将收到格式为 dstack-prod_dcbs- 的每日索引。 I want to add ILM to them, immediately after they are revived.我想在它们恢复后立即向它们添加 ILM。 I dont know why ILM are not added to indexs.我不知道为什么 ILM 没有添加到索引中。 below you can find my command.(I have already defined "dstack-prod_dcbs-policy" ILM)下面你可以找到我的命令。(我已经定义了“dstack-prod_dcbs-policy”ILM)

*PUT _template/dstack-prod_dcbs
{
  "index_patterns": ["dstack-prod_dcbs-*"], 
  "settings": {
    "index.lifecycle.name": "dstack-prod_dcbs-policy"
}
}*

but when I run但是当我跑的时候

GET dstack-prod_dcbs /_ilm/explain * GET dstack-prod_dcbs /_ilm/解释*

below result returns以下结果返回

*{
  "indices" : {
    "dstack-prod_dcbs-20200821" : {
      "index" : "dstack-prod_dcbs-20200821",
      "managed" : false
    },
    "dstack-prod_dcbs-2020-09-22" : {
      "index" : "dstack-prod_dcbs-2020-09-22",
      "managed" : false
    }
  }
}*

I believe ILM is an alternative to using daily indices where indices are rolled over when a condition is met in the policy (not when it becomes a new day)我相信 ILM 是使用每日指数的替代方法,当满足政策中的条件时(而不是当它成为新的一天时),指数会滚动

For ILM you need to define a rollover alias for the template对于 ILM,您需要为模板定义翻转别名

PUT _template/dstack-prod_dcbs
{
  "index_patterns": ["dstack-prod_dcbs-*"], 
  "settings": {
    "index.lifecycle.name": "dstack-prod_dcbs-policy",
    "index.lifecycle.rollover_alias": "dstack-prod_dcbs"
  } 
}

Then you need to create the first index manually and assign it as the write index for the alias然后您需要手动创建第一个索引并将其分配为别名的写入索引

PUT dstack-prod_dcbs-000001
{
   "aliases": {
        "dstack-prod_dcbs":{
            "is_write_index": true 
        }
    }
}

After that everything will be handled automatically and a new index will be created on rollover which will be then assigned as the write index for the alias之后一切都将自动处理,并在翻转时创建一个新索引,然后将其分配为别名的写入索引

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM