elasticsearch-curator  是官方收购的开源社区周边产品,用来管理es的索引和快照。 在6.6以后官方推出了ILM(索引生命周期管理策略),更加易于操作和方便使用,可以在kibana界面直接操作。

官方文档:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html

功能包括:从别名添加、删除索引,更改分片路由分配,打开/关闭索引,创建/删除索引,快照管理、合并segment,更改索引分片副本数等。

目前使用的elasticsearch-curator版本是5.4, Python2.6安装会出现问题.建议在安装在python2.7+的环境中.

安装:

# pip install elasticsearch-curator

使用:

命令语法:

命令行参数:  curator [--config CONFIG.YML] [--dry-run] ACTION_FILE.YML

$ curator --help
Usage: curator [OPTIONS] ACTION_FILE Curator for Elasticsearch indices.
See http://elastic.co/guide/en/elasticsearch/client/curator/current
Options:
--config PATH Path to configuration file. Default: ~/.curator/curator.yml
--dry-run Do not perform any changes. #  --dry-run参数在调试action_file时比较重要
--version Show the version and exit.
--help Show this message and exit.

curator运行需两个配置文件:

config.yml:用于连接ES集群配置

action.yml:用于配置要执行的操作,文件名称可以随意命名

config.yml配置:

# cat curator.yml
# Remember, leave a key empty ifthere is no value. None will be a string,
# not a Python "NoneType"
client:
hosts:
- 172.16.10.23
- 172.16.10.24
- 172.16.10.25
port: 9200
url_prefix:
use_ssl: False
certificate:
client_cert:
client_key:
ssl_no_validate: False
http_auth:
timeout: 3600
master_only: False
logging:
loglevel: INFO
# logfile: /home/test/curator.log
logfile:
logformat: default
blacklist: ['elasticsearch', 'urllib3']

配置说明:

  • hosts: 同一个集群内节点IP,如果端口不同,可写成ip:port形式;只能一次使用一个集群。在主机设置中包含来自多个集群的节点将导致错误。
  • port: 默认值是9200。这个值只适用于没有端口的主机。
  • timeout:  默认值是30S,根据实际使用情况调整.
  • logfile: 默认值是空的,会将执行结果输出到STDOUT或控制台。如果指定文件,会把执行日志输出到文件中,而不是控制台.
  • blacklist:  默认值为'elasticsearch', 'urllib3'。Python模块不被输出。除非需要调试某些问题, 否则请使用默认值.

ACTION_FILE配置

配置说明:关闭前缀为syslog- 并且 时间格式为 '%Y.%m.%d'的7天前的所有的文档.

# cat action_close.yml
---
# Remember, leave a key empty ifthere 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 thisaction as a template, be sure to set thisto False after
# copying it.
actions:
1:
action: close
description: >-
Close indices older than 30days (based on index name), forlogstash-
prefixed indices.
options:
delete_aliases: False
disable_action: False
filters: # filters下的配置都是隐含的逻辑“AND”操作链接.
- filtertype: pattern
kind: prefix
value: syslog-
- filtertype: age
source: name
direction: older
timestring: '%Y.%m.%d'
unit: days
unit_count: 7

curator_cli命令行命令行查看所有索引:

# curator_cli --config   config.yml  action_close.yml  --verbose

执行命令:

# curator --config  config.yml   action_close.yml

es索引管理工具-curator的更多相关文章

  1. ElasticSearch 命令行管理工具Curator

    一.背景 elastic官网现在已经大面积升级到了5.x版本,然而针对elasticsearch的命令行管理工具curator现在仍然是4.0版本. 刚开始找到此工具,深深的怕因为版本更迭无法使用,还 ...

  2. ElasticSearch——Curator索引管理

    简介 curator 是一个官方的,可以管理elasticsearch索引的工具,可以实现创建,删除,段合并等等操作.详见官方文档 功能 curator允许对索引和快照执行许多不同的操作,包括: 从别 ...

  3. 这么简单的ES索引生命周期管理,不了解一下吗~

    对于日志或指标(metric)类时序性强的ES索引,因为数据量大,并且写入和查询大多都是近期时间内的数据.我们可以采用hot-warm-cold架构将索引数据切分成hot/warm/cold的索引.h ...

  4. elk中es集群web管理工具cerebro

    cerebo是kopf在es5上的替代者 安装es虽然不能再root下运行,但是cerebro 可以 run as root is ok wget https://github.com/lmeneze ...

  5. Luke 5—— 可视化 Lucene 索引查看工具,可以查看ES的索引

    Luke 5 发布,可视化 Lucene 索引查看工具  oschina 发布于2015年08月31日  这是一个主要版本,该版本支持 Lucene 5.2.0. 它支持 elasticsearch ...

  6. SQL索引管理器 - 用于SQL Server和Azure上的索引维护的免费GUI工具

    我作为SQL Server DBA工作了8年多,管理和优化服务器的性能.在我的空闲时间,我想为宇宙和我的同事做一些有用的事情.这就是我们最终为SQL Server和Azure 提供免费索引维护工具的方 ...

  7. elasticsearch集群管理工具head插件(转)

    elasticsearch-head是一个elasticsearch的集群管理工具,它是完全由html5编写的独立网页程序,你可以通过插件把它集成到es 插件安装方法1: 1.elasticsearc ...

  8. Elasticsearch集群管理工具head插件安装

    Elasticsearch-head是一个elasticsearch的集群管理工具,它是完全由html5编写的独立网页程序,你可以通过插件把它集成到es.或直接下载源码,在本地打开index.html ...

  9. Elasticsearch ES索引

    ES是一个基于RESTful web接口并且构建在Apache Lucene之上的开源分布式搜索引擎. 同时ES还是一个分布式文档数据库,其中每个字段均可被索引,而且每个字段的数据均可被搜索,能够横向 ...

随机推荐

  1. luogu P1003 铺地毯

    水题 #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; t ...

  2. js 常用代码

    //获取url中的参数 function getUrlParam(name) { var reg = new RegExp("(^|&)" + name + "= ...

  3. h5页面实战——与andriod和ios的交互

    首先需要我们h5页面需要做一些匹配.比如:如何判断当前手机是andriod还是ios, andriod攻城狮和ios工程师,一般会定义事件的方法.我们套用他们方法就可以了. 那么为什么我要写这个随笔呢 ...

  4. Keepalived配置文件详解

    global_defs { router_id LVS_$prio #节点唯一标识,通常为hostname } local_address_group laddr_g1 { ${lvs_node} # ...

  5. java RSA实现私钥签名、公钥验签、私钥加密数据、公钥解密数据

    通过OpenSSL生成公私钥文件(如果没有OpenSSL工具建议下载Cmder工具自带OpenSSL指令) 1.生成RSA密钥的方法 genrsa -out private-rsa.key 2048 ...

  6. 接触node第一步

    趁着工作不忙,今天来系统记录一下安装node环境: 1.node下载地址为:https://nodejs.org/en/,检查是否安装成功:如果输出版本号,说明我们安装node环境成功:node -v ...

  7. 利用mybatis-generator自动生成代码,发生:Plugin execution not covered by lifecycle configuration后解决方案

    1,报错信息 Plugin execution not covered by lifecycle configuration: org.mybatis.generator:mybatis-genera ...

  8. KVO的使用二:常用方法及小技巧

    (文章及代码接上一篇) options详解: KVO的注册方法中有一个options枚举,用来确定观察者的接收消息方法接收的信息,那么具体有什么关联呢?下面通过一段代码来验证是如何关联的.依次选择op ...

  9. mybatis配置与使用

    一:Mybatis简介 1.名称由来 Mybatis原名叫ibatis.Mybatis一开始属于Apache,2010年从Apache转移到了GoogleCode这个组织中. 2.Mybatis概念 ...

  10. 让selenium中的Cromerderive不加载图片设置

    把配置参数(chrom_opt)设置好后将其添加到 browser = webdriver.Chrome(executable_path="chromedriver.exe的路径" ...