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

相关文章

Python脚本实现自动删除C盘临时文件夹

《Python脚本实现自动删除C盘临时文件夹》在日常使用电脑的过程中,临时文件夹往往会积累大量的无用数据,占用宝贵的磁盘空间,下面我们就来看看Python如何通过脚本实现自动删除C盘临时文件夹吧... 目录一、准备工作二、python脚本编写三、脚本解析四、运行脚本五、案例演示六、注意事项七、总结在日常使用

Git中恢复已删除分支的几种方法

《Git中恢复已删除分支的几种方法》:本文主要介绍在Git中恢复已删除分支的几种方法,包括查找提交记录、恢复分支、推送恢复的分支等步骤,文中通过代码介绍的非常详细,需要的朋友可以参考下... 目录1. 恢复本地删除的分支场景方法2. 恢复远程删除的分支场景方法3. 恢复未推送的本地删除分支场景方法4. 恢复

使用Python实现在Word中添加或删除超链接

《使用Python实现在Word中添加或删除超链接》在Word文档中,超链接是一种将文本或图像连接到其他文档、网页或同一文档中不同部分的功能,本文将为大家介绍一下Python如何实现在Word中添加或... 在Word文档中,超链接是一种将文本或图像连接到其他文档、网页或同一文档中不同部分的功能。通过添加超

关于Maven生命周期相关命令演示

《关于Maven生命周期相关命令演示》Maven的生命周期分为Clean、Default和Site三个主要阶段,每个阶段包含多个关键步骤,如清理、编译、测试、打包等,通过执行相应的Maven命令,可以... 目录1. Maven 生命周期概述1.1 Clean Lifecycle1.2 Default Li

Java操作ElasticSearch的实例详解

《Java操作ElasticSearch的实例详解》Elasticsearch是一个分布式的搜索和分析引擎,广泛用于全文搜索、日志分析等场景,本文将介绍如何在Java应用中使用Elastics... 目录简介环境准备1. 安装 Elasticsearch2. 添加依赖连接 Elasticsearch1. 创

Oracle数据库使用 listagg去重删除重复数据的方法汇总

《Oracle数据库使用listagg去重删除重复数据的方法汇总》文章介绍了在Oracle数据库中使用LISTAGG和XMLAGG函数进行字符串聚合并去重的方法,包括去重聚合、使用XML解析和CLO... 目录案例表第一种:使用wm_concat() + distinct去重聚合第二种:使用listagg,

怎么关闭Ubuntu无人值守升级? Ubuntu禁止自动更新的技巧

《怎么关闭Ubuntu无人值守升级?Ubuntu禁止自动更新的技巧》UbuntuLinux系统禁止自动更新的时候,提示“无人值守升级在关机期间,请不要关闭计算机进程”,该怎么解决这个问题?详细请看... 本教程教你如何处理无人值守的升级,即 Ubuntu linux 的自动系统更新。来源:https://

Redis过期键删除策略解读

《Redis过期键删除策略解读》Redis通过惰性删除策略和定期删除策略来管理过期键,惰性删除策略在键被访问时检查是否过期并删除,节省CPU开销但可能导致过期键滞留,定期删除策略定期扫描并删除过期键,... 目录1.Redis使用两种不同的策略来删除过期键,分别是惰性删除策略和定期删除策略1.1惰性删除策略

SpringBoot项目删除Bean或者不加载Bean的问题解决

《SpringBoot项目删除Bean或者不加载Bean的问题解决》文章介绍了在SpringBoot项目中如何使用@ComponentScan注解和自定义过滤器实现不加载某些Bean的方法,本文通过实... 使用@ComponentScan注解中的@ComponentScan.Filter标记不加载。@C

MySQL中删除重复数据SQL的三种写法

《MySQL中删除重复数据SQL的三种写法》:本文主要介绍MySQL中删除重复数据SQL的三种写法,文中通过代码示例讲解的非常详细,对大家的学习或工作有一定的帮助,需要的朋友可以参考下... 目录方法一:使用 left join + 子查询删除重复数据(推荐)方法二:创建临时表(需分多步执行,逻辑清晰,但会