elasticsearch-curator 实现索引删除、索引备份snapshot、删除snapshot

官方地址:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html
特性介绍:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/about-features.html

1.下载安装

wget https://packages.elastic.co/curator/5/centos/7/Packages/elasticsearch-curator-5.6.0-1.x86_64.rpm
yum install elasticsearch-curator-5.6.0-1.x86_64.rpm
#进入elasticsearch-curator,curator运行需两个配置文件config.yml(用于连接ES集群配置)、action.yml(用于配置要执行的操作),文件名称可以随意命名
touch action.yml
touch config.yml

2.配置action.yml & config.yml

以下示例:索引删除、索引备份snapshot、删除snapshot

actions:
  1:
    action: delete_indices
    description: >-
      Delete indices older than 7 days (based on index name), for testjiwei-
      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: False
      timeout_override: 300
      continue_if_exception: False
    filters:
    - filtertype: pattern
      kind: prefix
      value: testjiwei-
    - filtertype: age
      source: name
      direction: older
      timestring: '%Y.%m.%d'
      unit: days
      unit_count: 7
 2:
    action: snapshot
    description: >-
      Snapshot selected indices to 'repository' with the snapshot name or name
    options:
      repository: dev_data
      name:
      #name: '<paper-cource-playback-{now/d}>'  #自命名的snapshot测试有点问题,name空时默认已curator_时间戳自动生成
      wait_for_completion: True
      max_wait: 3600
      wait_interval: 10
      # true 不执行
      disable_action: False 
    filters:
    - filtertype: pattern
      kind: regex
      value: '^(ua_paper|course_exercise_extra|playback_info)'
 3:
    action: delete_snapshots
    description: >-
      Delete selected snapshots from 'repository'
    options:
      repository: dev_data     
      ignore_empty_list: True
      disable_action: False
      timeout_override: 3000
      continue_if_exception: False
    filters:
    - filtertype: pattern
      kind: prefix
      value: curator-
    - filtertype: age
      source: creation_date
      direction: older
      unit: days
      unit_count: 2  #删除2天以前的,0删除当天的

3.运行

# --dry-run 模拟执行,实际不做任何操作,可用于测试索引匹配是否正确
curator --config /opt/elasticsearch-curator/config.yml --dry-run /opt/elasticsearch-curator/action.yml
# 真实执行
curator --config /opt/elasticsearch-curator/config.yml /opt/elasticsearch-curator/action.yml
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值