使用curator 来管理elasticsearch的index
这里我们参考官网安装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的更多相关文章
- ElasticSearch——Curator索引管理
简介 curator 是一个官方的,可以管理elasticsearch索引的工具,可以实现创建,删除,段合并等等操作.详见官方文档 功能 curator允许对索引和快照执行许多不同的操作,包括: 从别 ...
- 高效管理 Elasticsearch 中基于时间的索引——本质是在利用滚动模式做数据的冷热分离,热索引可以用ssd
高效管理 Elasticsearch 中基于时间的索引 转自:http://stormluke.me/es-managing-time-based-indices-efficiently/ 用 Ela ...
- Elasticsearch:Index生命周期管理入门
如果您要处理时间序列数据,则不想将所有内容连续转储到单个索引中. 取而代之的是,您可以定期将数据滚动到新索引,以防止数据过大而又缓慢又昂贵. 随着索引的老化和查询频率的降低,您可能会将其转移到价格较低 ...
- ES 08 - 创建、查看、修改、删除、关闭Elasticsearch的index
目录 1 创建index(配置mapping[映射]) 2 查看index 3 修改index 4 删除index 5 打开/关闭index 6 常见问题及解决方法 index相当于RDBMS(关系型 ...
- 【ELK】4.spring boot 2.X集成ES spring-data-ES 进行CRUD操作 完整版+kibana管理ES的index操作
spring boot 2.X集成ES 进行CRUD操作 完整版 内容包括: ============================================================ ...
- 第05章 管理ElasticSearch
本章内容 如何选择正确的目录实现,使得ElasticSearch能够以高效的方式访问底层I/O系统. 如何配置发现模块来避免潜在的问题. 如何配置网关模块以适应我们的需求. 恢复模块能带来什么,以及如 ...
- Elasticsearch:Index alias
现在让我们来谈谈Elasticsearch最简单和最有用的功能之一:别名 (alias).为了区分这里alias和文章"Elasticsearch : alias数据类型",这里的 ...
- ES 05 - 通过Kibana管理Elasticsearch集群服务
目录 1 检查集群的健康状况 2 查看集群中的节点个数 3 查看集群中的索引 4 简单的索引操作 4.1 创建索引 4.2 删除索引 在本篇文章之前, 需要完成: ① 启动Elasticsearch服 ...
- elasticsearch 处理index 一直INITIALIZING状态
elasticsearch一个节点异常重启后有一个index恢复的过程中状态一直INITIALIZING 处理方法 PUT index_name/_settings { "index&quo ...
随机推荐
- SSH使用Slf4j
1. Slf4j的使用 在上一篇随笔:SSH使用Log4j的基础上配置. (1)导入两个文件:slf4j-api-1.5.8.jar和slf4j-log4j12-1.5.8.jar. (2)在需要日志 ...
- 利用 pywin32 操作 excel
from win32com.client import Dispatch import win32com.client import time # 获取excel 对象 excel = win32co ...
- SpringBoot启动器详解pom.xml
Spring Boot应用启动器基本的一共有44种,具体如下: 1)spring-boot-starter 这是Spring Boot的核心启动器,包含了自动配置.日志和YAML. 2)spring- ...
- Statement、PreparedStatemnt、CallableStatement
第一.Statement(Statement代表一个特定的容器,来对一个特定的数据库执行语句) * 执行查询的方法 Statement=Connection.createStatement();//创 ...
- RSA密钥生成、加密解密、签名验签
RSA 非对称加密公钥加密,私钥解密 私钥签名,公钥验签 下面是生成随机密钥对: //随机生成密钥对 KeyPairGenerator keyPairGen = null; try { keyPair ...
- python必须要安装的库
1.requests 2.lxml 3.Django 4.BeautifulSoup 5.PyMySQL-0.7.0 (适用于python3) 6.图片处理PIL
- nmake构建Geos库
1.下载源码包 下载地址 http://download.osgeo.org/geos/geos-3.6.1.tar.bz2 下载之后解压即可. 2.编译 geos源码包中自带了makefile.vc ...
- codevs 1013 求先序排列
题目链接:http://codevs.cn/problem/1013/ 题目描述 Description 给出一棵二叉树的中序与后序排列.求出它的先序排列.(约定树结点用不同的大写字母表示,长度< ...
- topshelf 开发windows 服务资料
官方配置 http://docs.topshelf-project.com/en/latest/configuration/config_api.html#service-start-modes to ...
- 用命令行发邮件——让你更加了解smtp
本文演示用命令行发送邮件的过程. SMTP 首先介绍下smtp协议--简单邮件传输协议 (Simple Mail Transfer Protocol, SMTP) 是事实上的在Internet传输em ...