elasticsearch-curator: es索引生命周期(关闭、删除索引)

2024-01-02 19:04

本文主要是介绍elasticsearch-curator: es索引生命周期(关闭、删除索引),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1,下载安装

  • rpm包下载安装
# 防止安装rpm包报错:error: [upel]: elasticsearch-curator NOKEY ; 
#                  error: [upel]: elasticsearch-curator signature check fail
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch #参考https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rpm.htmlrpm -ivh https://packages.elastic.co/curator/5/centos/7/Packages/elasticsearch-curator-5.8.4-1.x86_64.rpm
  • 参考:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/installation.html

2, 配置使用

配置

  • 关闭索引,action.yaml 加上 ignore_empty_list: True, 防止条件不满足时报错,导致任务不能继续执行
  • 删除索引,action.yaml 加上continue_if_exception: True , 防止删除索引报错,导致任务不能继续执行
  • action.yaml 配置参考:
    action-close模板:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/ex_close.html
  • 索引名匹配-正则参考:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/filtertype_pattern.html
TEST1:/root # cat curator-close.yml
---
actions:1:action: closedescription: >-关闭指定索引,5天前的:test_logstash_options:skip_flush: Falsedelete_aliases: Falseignore_sync_failures: Trueignore_empty_list: Truedisable_action: Falsefilters:- filtertype: patternkind: prefix#value: test_logstash_2023_11_12value: test_logstash_- filtertype: agesource: namedirection: older#timestring: '%Y.%m.%d'timestring: '%Y_%m_%d'unit: daysunit_count: 52:action: closedescription: >-关闭指定索引,10天前的:^(\w+)_logstash_.*$options:skip_flush: Falsedelete_aliases: Falseignore_sync_failures: Trueignore_empty_list: Truedisable_action: Falsefilters:- filtertype: patternkind: regex#value: logstash-#value: test_logstash_2023_11_12value: '^(\w+)_logstash_.*$'- filtertype: agesource: namedirection: older#timestring: '%Y.%m.%d'timestring: '%Y_%m_%d'unit: daysunit_count: 103:action: delete_indicesdescription: >-删除过期30天的索引: 按天存储options:ignore_empty_list: Truecontinue_if_exception: Truedisable_action: Falsefilters:- filtertype: patternkind: regex#value: test_logstash_2023_11_12value: '^(\w+)_logstash_.*$'- filtertype: agesource: namedirection: older#timestring: '%Y.%m.%d'timestring: '%Y_%m_%d'unit: daysunit_count: 314:action: delete_indicesdescription: >-删除过期30天的索引: 按月存储options:ignore_empty_list: Truecontinue_if_exception: Truedisable_action: Falsefilters:- filtertype: patternkind: regex#value: logstash-#value: test_logstash_2023_11_12value: '^(\w+)_logstash_(\d{4}\S\d{2})$'- filtertype: agesource: namedirection: older#timestring: '%Y.%m.%d'timestring: '%Y_%m_%d'unit: daysunit_count: 60TEST1:/root # cat curator/curatorConfig.yaml 
client:hosts:- 185.86.0.106- 185.86.0.107- 185.86.0.108port: 9200url_prefix:use_ssl: Falsecertificate:client_cert:client_key:ssl_no_validate: Falseusername: elasticpassword: elk123456timeout: 60master_only: Falselogging:loglevel: INFOlogfile: /applog/elk/curator/curator.loglogformat: defaultblacklist: ['elasticsearch', 'urllib3']

使用

  • curator --config 全局配置文件 action动作配置文件
TEST1:/root # curator --config curator/curatorConfig.yaml  curator-close.yml  TEST1:/root #  tail  /applog/elk/curator/curator.log -f
2024-01-02 11:19:02,339 INFO      Preparing Action ID: 1, "close"
2024-01-02 11:19:02,339 INFO      Creating client object and testing connection
2024-01-02 11:19:02,341 INFO      Instantiating client object
2024-01-02 11:19:02,342 INFO      Testing client connectivity
2024-01-02 11:19:02,345 INFO      Successfully created Elasticsearch client object with provided settings
2024-01-02 11:19:02,348 INFO      Trying Action ID: 1, "close": 关闭指定索引,5天前的:test_logstash_
2024-01-02 11:19:04,088 INFO      Skipping action "close" due to empty list: <class 'curator.exceptions.NoIndices'>
2024-01-02 11:19:04,089 INFO      Action ID: 1, "close" completed.2024-01-02 11:19:04,089 INFO      Preparing Action ID: 2, "close"
2024-01-02 11:19:04,089 INFO      Creating client object and testing connection
2024-01-02 11:19:04,089 INFO      Instantiating client object
2024-01-02 11:19:04,090 INFO      Testing client connectivity
2024-01-02 11:19:04,095 INFO      Successfully created Elasticsearch client object with provided settings
2024-01-02 11:19:04,097 INFO      Trying Action ID: 2, "close": 关闭指定索引,10天前的:^(\w+)_logstash_.*$
2024-01-02 11:19:04,610 INFO      Closing 30 selected indices: [ 'test_net_logstash_2023_12_15', 'metric_net_logstash_2023_12_16', 'mytest_logstash_2023_12_15',... ]
2024-01-02 11:19:06,240 INFO      Action ID: 2, "close" completed.2024-01-02 13:49:45,975 INFO      Preparing Action ID: 3, "delete_indices"
2024-01-02 13:49:45,975 INFO      Creating client object and testing connection
2024-01-02 13:49:45,975 INFO      Instantiating client object
2024-01-02 13:49:45,976 INFO      Testing client connectivity
2024-01-02 13:49:45,978 INFO      Successfully created Elasticsearch client object with provided settings
2024-01-02 13:49:45,981 INFO      Trying Action ID: 3, "delete_indices": 删除过期30天的索引
2024-01-02 13:49:46,218 INFO      Deleting 8 selected indices: ['test123_logstash_2023_12_01', 'metric_logstash_2023_12_02', 'monitor_logstash_2023_12_02', ...]
2024-01-02 13:49:46,218 INFO      ---deleting index test123_logstash_2023_12_01
2024-01-02 13:49:46,218 INFO      ---deleting index metric_logstash_2023_12_02
2024-01-02 13:49:46,218 INFO      ---deleting index monitor_logstash_2023_12_02
2024-01-02 13:49:47,475 INFO      Action ID: 3, "delete_indices" completed.2024-01-02 13:50:49,047 INFO      Trying Action ID: 4, "delete_indices": 删除过期60天的索引: 按月存储
2024-01-02 13:50:49,326 INFO      Deleting 22 selected indices: ['test1_logstash_2023_11', 'test2_logstash_2023_12', 'test3_logstash_2023_11'...]
2024-01-02 13:50:49,326 INFO      ---deleting index test1_logstash_2023_11
2024-01-02 13:50:49,326 INFO      ---deleting index test2_logstash_2023_12
2024-01-02 13:50:49,326 INFO      ---deleting index test3_logstash_2023_11
...
2024-01-02 13:50:56,240 INFO      Job completed.

这篇关于elasticsearch-curator: es索引生命周期(关闭、删除索引)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/563371

相关文章

MySQL 数据库表操作完全指南:创建、读取、更新与删除实战

《MySQL数据库表操作完全指南:创建、读取、更新与删除实战》本文系统讲解MySQL表的增删查改(CURD)操作,涵盖创建、更新、查询、删除及插入查询结果,也是贯穿各类项目开发全流程的基础数据交互原... 目录mysql系列前言一、Create(创建)并插入数据1.1 单行数据 + 全列插入1.2 多行数据

mybatisplus的逻辑删除过程

《mybatisplus的逻辑删除过程》:本文主要介绍mybatisplus的逻辑删除过程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录myBATisplus的逻辑删除1、在配置文件中添加逻辑删除的字段2、在实体类上加上@TableLogic3、业务层正常删除即

MybatisPlus中removeById删除数据库未变解决方案

《MybatisPlus中removeById删除数据库未变解决方案》MyBatisPlus中,removeById需实体类标注@TableId注解以识别数据库主键,若字段名不一致,应通过value属... 目录MyBATisPlus中removeBypythonId删除数据库未变removeById(Se

MySQL 索引简介及常见的索引类型有哪些

《MySQL索引简介及常见的索引类型有哪些》MySQL索引是加速数据检索的特殊结构,用于存储列值与位置信息,常见的索引类型包括:主键索引、唯一索引、普通索引、复合索引、全文索引和空间索引等,本文介绍... 目录什么是 mysql 的索引?常见的索引类型有哪些?总结性回答详细解释1. MySQL 索引的概念2

Oracle查询表结构建表语句索引等方式

《Oracle查询表结构建表语句索引等方式》使用USER_TAB_COLUMNS查询表结构可避免系统隐藏字段(如LISTUSER的CLOB与VARCHAR2同名字段),这些字段可能为dbms_lob.... 目录oracle查询表结构建表语句索引1.用“USER_TAB_COLUMNS”查询表结构2.用“a

MySQL 强制使用特定索引的操作

《MySQL强制使用特定索引的操作》MySQL可通过FORCEINDEX、USEINDEX等语法强制查询使用特定索引,但优化器可能不采纳,需结合EXPLAIN分析执行计划,避免性能下降,注意版本差异... 目录1. 使用FORCE INDEX语法2. 使用USE INDEX语法3. 使用IGNORE IND

MySQL逻辑删除与唯一索引冲突解决方案

《MySQL逻辑删除与唯一索引冲突解决方案》本文探讨MySQL逻辑删除与唯一索引冲突问题,提出四种解决方案:复合索引+时间戳、修改唯一字段、历史表、业务层校验,推荐方案1和方案3,适用于不同场景,感兴... 目录问题背景问题复现解决方案解决方案1.复合唯一索引 + 时间戳删除字段解决方案2:删除后修改唯一字

SpringBoot整合(ES)ElasticSearch7.8实践

《SpringBoot整合(ES)ElasticSearch7.8实践》本文详细介绍了SpringBoot整合ElasticSearch7.8的教程,涵盖依赖添加、客户端初始化、索引创建与获取、批量插... 目录SpringBoot整合ElasticSearch7.8添加依赖初始化创建SpringBoot项

使用Python删除Excel中的行列和单元格示例详解

《使用Python删除Excel中的行列和单元格示例详解》在处理Excel数据时,删除不需要的行、列或单元格是一项常见且必要的操作,本文将使用Python脚本实现对Excel表格的高效自动化处理,感兴... 目录开发环境准备使用 python 删除 Excphpel 表格中的行删除特定行删除空白行删除含指定

Linux下删除乱码文件和目录的实现方式

《Linux下删除乱码文件和目录的实现方式》:本文主要介绍Linux下删除乱码文件和目录的实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux下删除乱码文件和目录方法1方法2总结Linux下删除乱码文件和目录方法1使用ls -i命令找到文件或目录