官网教程入口:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html

一、下载安装

  • 下载:sudo pip install elasticsearch-curator
  • 更新:sudo pip install -U elasticsearch-curator

版本:curator4.1.0

二、配置文件

1、config.yml

# Remember, leave a key empty if there is no value.  None will be a string,
# not a Python "NoneType"
client:
  hosts: ["127.0.0.1:9200"]
  url_prefix:
  use_ssl: False
  certificate:
  client_cert:
  client_key:
  aws_key:
  aws_secret_key:
  aws_region:
  ssl_no_validate: False
  http_auth:
  timeout: 30
  master_only: False

logging:
  loglevel: INFO
  logfile:
  logformat: default
  blacklist: ['elasticsearch', 'urllib3']

说明:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/configfile.html

2、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 indices older than 45 days (based on index name), for logstash- prefixed indices.
                  Ignore the error if the filter does not result in an actionable list of indices (ignore_empty_list) and exit cleanly"
    options:
      timeout_override:
      continue_if_exception: False
      disable_action: False
    filters:
    - filtertype: pattern
      kind: prefix
      value: logstash-
      exclude:
    - filtertype: age
      source: name
      direction: older
      timestring: '%Y.%m.%d'
      unit: days
      unit_count: 5
      exclude:

注意:action上边那个1是action id,必须得有

说明:

三、测试

curator --config ~/Desktop/server/elk/es-curator-4.1.0/config.yml ~/Desktop/server/elk/es-curator-4.1.0/action.yml

四、做成Linux定时任务

1、编写sh脚本:curator-delete-index.sh

#!/bin/sh
/usr/local/bin/curator --config /Users/enniu1/Desktop/server/elk/es-curator-4.1.0/config.yml /Users/enniu1/Desktop/server/elk/es-curator-4.1.0/action.yml
echo "delete index success"

注意:最好使用命令的全路径名,否则可能找不到。

2、赋予权限

  • chmod 777 /Users/enniu1/Desktop/server/elk/es-curator-4.1.0/curator-delete-index.sh

3、创建定时任务:crontab

  • crontab -e:打开了vi,输入:

    • 30 16 * * * /Users/enniu1/Desktop/server/elk/es-curator-4.1.0/curator-delete-index.sh,之后保存退出vi

  • crontab -l:查看所有的root用户的定时任务

附:crontab的文件格式

分 时 日 月 星期 要运行的命令

  • 第1列分钟1~59
  • 第2列小时1~23(0表示子夜)
  • 第3列日1~31
  • 第4列月1~12
  • 第5列星期0~7(0和7表示星期天)
  • 第6列要运行的命令

【附9】elasticsearch-curator + Linux定时任务的更多相关文章

  1. 附9 elasticsearch-curator + Linux定时任务

    官网教程入口:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html 一.下载安装 下载:sud ...

  2. linux定时任务crond export变量问题

    linux定时任务crond export变量问题 1)我写了一个重启resin的脚本,由于业务原因,需要定时在某一个时间重启下resin服务器,于是就在 crontab里配置了如下内容: 50 17 ...

  3. Linux 定时任务

    200 ? "200px" : this.width)!important;} --> 介绍 本篇主要介绍Linux定时任务命令crontab的用法,crontab是定时任务 ...

  4. Linux 定时任务 Crontab命令 详解

    前言 crontab是Unix和Linux用于设置周期性被执行的指令,是互联网很常用的技术,很多任务都会设置在crontab循环执行,如果不使用crontab,那么任务就是常驻程序,这对你的程序要求比 ...

  5. 如何让Linux定时任务crond以秒为单位执行(如每隔3秒)

    需要用到Shell脚本每隔3秒钟去监控一个软件进程的运行状态,发现crond似乎只支持到分,不知道秒,怎么办呢? 第一种方法: 当然首先想到的是写一个触发的脚本,在触发脚本中使用死循环来解决此问题,如 ...

  6. 工作中linux定时任务的设置及相关配置

    工作中会用到定时任务,来处理以前采集来的数据备份, 每周一凌晨4点执行一次    0 4 * * */1 find/data/templatecdr/oracle/dcndatabak/ -type ...

  7. 如何让linux定时任务crontab按秒执行

    如何让linux定时任务crontab按秒执行? linux定时任务crontab最小执行时间单位为分钟如果想以秒为单位执行,应该如何设置呢?思路 正常情况是在crontab中直接定义要执行的任务,现 ...

  8. (转载)Linux定时任务cron配置

    (转载)http://blog.csdn.net/jbgtwang/article/details/7995801 实现linux定时任务有:cron.anacron.at等,这里主要介绍cron服务 ...

  9. linux定时任务crontab的设置

    linux定时任务crontab的设置http://www.blogjava.net/freeman1984/archive/2010/09/23/332715.html vi /etc/cronta ...

随机推荐

  1. 洛谷P3209平面图判定 [HNOI2010] 2-sat

    正解:2-sat(并茶几/强连通分量 解题报告: 传送门w 难受死了,连WA5次,正确率又-=INF了QAQ 然后先说下这题怎么做再来吐槽自己QAQ 首先这题其实和NOIp2010的关押罪犯挺像的,然 ...

  2. H5,PC网页屏幕尺寸相关整理(scrollLeft,scrollWidth,clientWidth,offsetWidth)

    HTML:scrollLeft,scrollWidth,clientWidth,offsetWidth到底指的哪到哪的距离之完全详解scrollHeight: 获取对象的滚动高度. scrollLef ...

  3. 深入了解oracle存储过程的优缺点

    定义: 存储过程(Stored Procedure )是一组为了完成特定功能的SQL 语句集,经编译后存储在数据库中.用户通过指定存储过程的名字并给出参数(如果该存储过程带有参数)来执行它.存储过程是 ...

  4. MySQL数据库运维课程

    MySQL数据库运维课程 http://www.dataguru.cn/article-4834-1.html?union_site=comm100 课程大纲 第一课:机器选型.系统规划 第二课:安装 ...

  5. idea 使用方法

    1:设置自定义自动补全,使用$END$代表最后光标所在的位置. http://blog.csdn.net/u012569796/article/details/54694418 2:使用 shift+ ...

  6. Knight Moves(hdu1372 bfs模板题)

    http://acm.hdu.edu.cn/showproblem.php?pid=1372 Knight Moves Time Limit: 2000/1000 MS (Java/Others)   ...

  7. ios 工作日志

    1.设计模式 1.1 想用一个controllerK控制多个页面的切换 但是每一个页面必须要引用这个controller,这样才能控制进度, 所以必须是弱引用.controller必须被某一个实例强引 ...

  8. Oracle获取数据库中的对象创建语句

    使用dbms_metadata.get_ddl()函数可以做到. 实验环境:Oracle 11.2.0.4 以获取jingyu用户下的T1表为例: SQL> conn jingyu/jingyu ...

  9. e.printStackTrace() ; 是什么意思?

    catch(Exception e){e.printStackTrace() ;} 当try语句中出现异常是时,会执行catch中的语句,java运行时系统会自动将catch括号中的Exception ...

  10. C# 开发圆角控件(窗体)

    最近在做卡片视图的程序,要求将控件做成带有圆角的效果,下面是我在网上查找的资料,经过测试,确定可以实现功能.其中方法三既适应于控件,也适应于窗体. 先上传效果图: 方法一: 增加命名空间:using  ...