文章详情

短信预约信息系统项目管理师 报名、考试、查分时间动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

Elasticsearch通过elasticsearch-curator 插件来定期删除Index

2022-04-28 19:07

关注

Elasticsearch通过elasticsearch-curator 插件来定期删除Index

Elasticsearch管理中索引的管理非常重要。基于磁盘空间和性能的考量,索引的生命周期管理显得尤为重要。Curator允许对索引创建、删除等操作,下面是我们借助 elasticsearch-curator 插件来定期删除index.本文主要介绍elasticsearch-curator 插件的安装步骤。

Step 1下载

https://www.elastic.co/guide/en/elasticsearch/client/curator/current/yum-repository.html

 

 

 Step 2 上传安装包至服务器,并创建相应的文件

 

Step 3 安装

执行的安装命令如下:

yum localinstall elasticsearch-curator-5.8.1-1.x86_64.rpm

Step 4  完善更新配置文件

 config.yml文件

详细内容如下:

---
# Remember, leave a key empty if there is no value.  None will be a string,
# not a Python "NoneType"
client:
  hosts:
    - 201.101.101.101
  port: 端口
  url_prefix:
  use_ssl: False
  certificate:
  client_cert:
  client_key:
  ssl_no_validate: False
  http_auth: 用户名:密码
  timeout: 30
  master_only: False

logging:
  loglevel: INFO
  logfile: /data/elasticsearch-curator/log/curator.log
  logformat: default
  blacklist: ["elasticsearch", "urllib3"]

action.yml 文件的编辑

 

 

 详细内容如下:

---
# Remember, leave a key empty if there is no value.  None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have "disable_action" set to True.  If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
  1:
    action: delete_indices
    description: >-
      Delete metric indices older than 3 days (based on index name), for
      .monitoring-es-6-
      .monitoring-kibana-6-
      .monitoring-logstash-6-
      .watcher-history-3-
      prefixed indices. Ignore the error if the filter does not result in an
      actionable list of indices (ignore_empty_list) and exit cleanly.
    options:
      ignore_empty_list: True
 #     disable_action: True
    filters:
    - filtertype: pattern
      kind: regex
      value: "^mysql-.*$"
    - filtertype: age
      source: name
      direction: older
      timestring: "%Y.%m.%d"
      unit: days
      unit_count: 3

  2:
    action: close
    description: >-
      Close indices older than 30 days (based on index name), for syslog-
      prefixed indices.
    options:
      ignore_empty_list: True
      delete_aliases: False
#      disable_action: True
    filters:
    - filtertype: pattern
      kind: prefix
      value: syslog-
    - filtertype: age
      source: name
      direction: older
      timestring: "%Y.%m.%d"
      unit: days
      unit_count: 30

  3:
    action: forcemerge
    description: >-
      forceMerge syslog- prefixed indices older than 2 days (based on index
      creation_date) to 2 segments per shard.  Delay 120 seconds between each
      forceMerge operation to allow the cluster to quiesce. Skip indices that
      have already been forcemerged to the minimum number of segments to avoid
      reprocessing.
    options:
      ignore_empty_list: True
      max_num_segments: 2
      delay: 120
      timeout_override:
      continue_if_exception: False
    filters:
    - filtertype: pattern
      kind: prefix
      value: syslog-
      exclude:
    - filtertype: age
      source: name
      direction: older
      timestring: "%Y.%m.%d"
      unit: days
      unit_count: 2
    - filtertype: forcemerged
      max_num_segments: 2
      exclude:

Step 5 使用crontab定期执行curator

设置定时任务,例如以下的crontab

6 0 * * * curator --config /data/elasticsearch-curator/config.yml /data/elasticsearch-curator/action.yml

 

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-数据库
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯