这里我们参考官网安装curator

https://www.cookiesinn.org/elasticsearch_curator_delete_indices/

https://www.elastic.co/guide/en/elasticsearch/client/curator/5.4/installation.html

https://blog.csdn.net/u013613428/article/details/78229090

https://blog.csdn.net/zou79189747/article/details/80526221

这里我们使用yum 的方式来安装

先说 一下我的环境:

centos 7

es 5.6.9

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

cd /data/package
sudo rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch cd /etc/yum.repos.d
vim elasticsearch.repo [curator-5]
name=CentOS/RHEL 7 repository for Elasticsearch Curator 5.x packages
baseurl=https://packages.elastic.co/curator/5/centos/7
gpgcheck=1
gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1 sudo yum install elasticsearch-curator

正题看下面:

curator由python研发的非常轻量级的工具.

curator不仅仅可以删除多余的索引其实还有其他功能也能使用比如:添加别名、创建快照、删除快照、添加索引、删除索引、索引设置等等内容。并且可以将这些设置定义在YAML风格的配置文件

我们目前用到的是对index的过期删除,这里我们要注意的是,我们的index的命名最好是有规范的。这样对我们的index管理起来是方便的。最好是  “业务-服务-date”

1、下载rpm包并且安装Elasticsearch-curator:

cd /data/tools

wget https://packages.elastic.co/curator/5/centos/7/Packages/elasticsearch-curator-5.3.0-1.x86_64.rpm

sudo yum install -y elasticsearch-curator-5.2.-.x86_64.rpm #安装会安装在/opt目录下

我们常用的是curator和curator_cli,具体的参见官网:

https://www.elastic.co/guide/en/elasticsearch/client/curator/5.3/filtertype_age.html

curator_cli --host 127.0.0.1 --port 9200 show_indices --verbose

这样我们直接上正题:直接删除过期的index

mkdir

/data/package/curator

这里我们在编写配置文件的时候,一定要注意缩进,yml 语法对这个要求很严格

首先我们配置vim config.yml

client:
hosts:
- 10.10.124.125
- 10.10.96.46
port: 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']

现在我们上清理索引的配置:

这里我是删除了所有的超过七天的index,同时我们也可以使用 filtertype: pattern 匹配规则来删除相应的index,这里就提现出我们在命名index的是有规则是有多么的重要

actions:
:
action: delete_indices
description: "Delect all index"
options:
ignore_empty_list: True
disable_action: False
filters:
# - filtertype: pattern
# kind: regex
# value: test2
- filtertype: age
source: creation_date
direction: older
unit: days
unit_count:

一个索引进行匹配只能定义在一个任务中,除非是像我上面一样,直接就是根据filtertype: age来。

注意:再次提示,这里最好不要复制粘贴文件,可能一不小心就把缩进给弄乱了,真想复制粘贴可以复制官网上的,这样格式不会乱

这里我们调试使用的命令是:

 curator --config config.yml delete_index.yml --dry-run

真正执行的命令是:

 curator --config config.yml delete_index.yml 

真正上线的时候我们结合crontab 一起使用,这样我们就可以实现定时的去清理elasticsearch  index  的目的了,妈妈在用不用担心我们磁盘满了,
以前都是用脚本处理的,因为以前的elasticsearch的index数据文件是有规则的,现在是一串字符串,不好用脚本处理,发现了这个开源工具,真的很好用。强烈推荐

使用curator 来管理elasticsearch的index的更多相关文章

  1. ElasticSearch——Curator索引管理

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

  2. 高效管理 Elasticsearch 中基于时间的索引——本质是在利用滚动模式做数据的冷热分离,热索引可以用ssd

    高效管理 Elasticsearch 中基于时间的索引 转自:http://stormluke.me/es-managing-time-based-indices-efficiently/ 用 Ela ...

  3. Elasticsearch:Index生命周期管理入门

    如果您要处理时间序列数据,则不想将所有内容连续转储到单个索引中. 取而代之的是,您可以定期将数据滚动到新索引,以防止数据过大而又缓慢又昂贵. 随着索引的老化和查询频率的降低,您可能会将其转移到价格较低 ...

  4. ES 08 - 创建、查看、修改、删除、关闭Elasticsearch的index

    目录 1 创建index(配置mapping[映射]) 2 查看index 3 修改index 4 删除index 5 打开/关闭index 6 常见问题及解决方法 index相当于RDBMS(关系型 ...

  5. 【ELK】4.spring boot 2.X集成ES spring-data-ES 进行CRUD操作 完整版+kibana管理ES的index操作

    spring boot 2.X集成ES 进行CRUD操作  完整版 内容包括: ============================================================ ...

  6. 第05章 管理ElasticSearch

    本章内容 如何选择正确的目录实现,使得ElasticSearch能够以高效的方式访问底层I/O系统. 如何配置发现模块来避免潜在的问题. 如何配置网关模块以适应我们的需求. 恢复模块能带来什么,以及如 ...

  7. Elasticsearch:Index alias

    现在让我们来谈谈Elasticsearch最简单和最有用的功能之一:别名 (alias).为了区分这里alias和文章"Elasticsearch : alias数据类型",这里的 ...

  8. ES 05 - 通过Kibana管理Elasticsearch集群服务

    目录 1 检查集群的健康状况 2 查看集群中的节点个数 3 查看集群中的索引 4 简单的索引操作 4.1 创建索引 4.2 删除索引 在本篇文章之前, 需要完成: ① 启动Elasticsearch服 ...

  9. elasticsearch 处理index 一直INITIALIZING状态

    elasticsearch一个节点异常重启后有一个index恢复的过程中状态一直INITIALIZING 处理方法 PUT index_name/_settings { "index&quo ...

随机推荐

  1. python从sqlite中提取数据到excel

    import sqlite3 as sqlite from xlwt import * import sys def sqlite_get_col_names(cur, select_sql): cu ...

  2. 解决mybatis报错Result Maps collection does not contain value for java.lang.Integer

    解决办法:1.检查mybatis的xml配置 2.在某处肯定有配错了的,如"resultMap" -->"resultType" [html] view ...

  3. Python文本爬虫实战

    转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/7019950.html  一:流程 目标:爬取目标网页的图片 1:获取网页源码 2:用Python读取源码 3: ...

  4. Nginx server之Nginx添加ssl支持

    //环境介绍 1.nginx服务器:10.10.54.157 2.配置nginx服务器,当监听到来自客户端www.zijian.com:80请求时,转到10.10.54.150:1500这个web服务 ...

  5. linux find command information more

    查找文件find ./ -type f 查找目录find ./ -type d 查找名字为test的文件或目录find ./ -name test 查找名字符合正则表达式的文件,注意前面的‘.*’(查 ...

  6. 批处理/命令行合并js,递归合并子目录js文件

    for /r %%i in (*.js) do type "%%i">>xxx-all.js java -jar yuicompressor.jar --type js ...

  7. python 之模块之 xml.dom.minidom解析xml

    # -*- coding: cp936 -*- #python 27 #xiaodeng #python 之模块之 xml.dom.minidom解析xml #http://www.cnblogs.c ...

  8. 基于kettle8的web端调度监控平台

    发布时间:2018-11-16   技术:spring+springmvc +beetlsql+quartz+kettle8   概述 Kettle调度监控平台(以下简称KS)是一个自主开发的java ...

  9. android.database.sqlite.SQLiteException: near "FROM"

      07-20 00:19:30.496: E/JavaBinder(6807): *** Uncaught remote exception!  (Exceptions are not yet su ...

  10. Swift 互斥锁写法

    oc中的互斥锁@synchronized(self) { //需要执行的代码块} swift中的互斥锁objc_sync_enter(self)//需要执行的代码块objc_sync_exit(sel ...