elasticsearch定时删除索引第二版
该版本对于上一个版本做了升级。兼容性更好了。
#!/bin/bash
#######################################################
# $Name: clean_index.sh
# $Version: v2.0
# $Function: delete es index
# $Author: dongjiaxiao
# $Create Date: 2019-12-31
# $Description: shell
######################################################
#脚本的日志文件路径
CLEAN_LOG="/home/djx/scripts/clean_index.log"
#es地址
SERVER_PORT=172.17.1.212:9200
#保留的时间,单位天
DELTIME=45
SECONDS=$(date -d "$(date +%F) -${DELTIME} days" +%s)
INDEXS=$(curl -s -u elastic:changeme "${SERVER_PORT}/_cat/indices?v"|awk '{print $3}')
echo "-------------------$(date +%F_%T)---------------" >>${CLEAN_LOG}
for del_index in ${INDEXS}
do
timeString=$( echo ${del_index} |awk -F"-" '{print $NF}'|egrep "[0-9]*\.[0-9]*\.[0-9]*")
if [ -n "$timeString" ]
then
indexDate=${timeString//./-}
indexSecond=$( date -d ${indexDate} +%s )
if [ $(( $SECONDS- $indexSecond )) -gt 0 ]
then
delResult=`curl -s -u elastic:changeme -XDELETE "${SERVER_PORT}/"${del_index}"?pretty" |sed -n '2p'`
echo "delete index:$del_index result:$delResult" >>${CLEAN_LOG}
fi
fi
done
elasticsearch定时删除索引第二版的更多相关文章
- Elasticsearch之删除索引
1. #删除指定索引 # curl -XDELETE -u elastic:changeme http://localhost:9200/acc-apply-2018.08.09 {&qu ...
- 第六篇 elasticsearch express 删除索引数据
express 框架删除elasticsearch索引数据 1.在elasticsearch.js文件下添加 function deleteDocument(id) { return elasticC ...
- 定时删除elasticsearch索引
从去年搭建了日志系统后,就没有去管它了,最近发现大半年各种日志的index也蛮多的,就想着写个脚本定时清理一下,把一些太久的日志清理掉. 脚本思路:通过获取index的尾部时间与我们设定的过期时间进行 ...
- Elasticsearch日志之删除索引
1.查询索引 [root@ecs-- elasticsearch]# curl -XGET http://localhost:9200/* {,,},},},,,},},},,,},},},,,},} ...
- ElasticSearch 定时批量删除N天前的数据
描述: 之前我已经完成了使用ElasticSearch.kibana.filebeat.三个工具完成分布式集群收集 分布在各个ip地址上的微服务日志,这样就可以统一的在一个服务器上查看了所有的微服务产 ...
- SQL优化 MySQL版 - 索引分类、创建方式、删除索引、查看索引、SQL性能问题
SQL优化 MySQL版 - 索引分类.创建方式.删除索引.查看索引.SQL性能问题 作者 Stanley 罗昊 [转载请注明出处和署名,谢谢!] 索引分类 单值索引 单的意思就是单列的值,比如说有 ...
- 【转】ElasticSearch之定时删除数据
有的时候我们在使用ES时,由于资源有限或业务需求,我们只想保存最近一段时间的数据,所以有如下脚本可以定时删除数据 delete_es_by_day.sh #!/bin/sh # example: in ...
- ElasticSearch.net NEST批量创建修改删除索引完整示例
本示例采用Elasticsearch+Nest 网上查了很多资料,发现用C#调用Elasticsearch搜索引擎的功能代码很分散,功能不完整,多半是非常简单的操作,没有成型的应用示例.比如新增或修改 ...
- elasticsearch删除索引报错【原】
如果elasticsearch删除索引报错 curl -X DELETE 'http://10.73.26.66:9200/httpd-34-2017.08.15' {"error" ...
随机推荐
- j2se--异常机制
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/quwenzhe/article/details/35610853 java异常机制中主要包含一个 ...
- 学习layer弹层组件移动版
layer弹层组件官网 常用参数: shadeClose:默认true,是否点击遮罩时关闭层
- ViewPager封装工具类: 轻松实现APP导航或APP中的广告栏
相信做app应用开发的,绝对都接触过ViewPager,毕竟ViewPager的应用可以说无处不在:APP第一次启动时的新手导航页,APP中结合Fragment实现页面滑动,APP中常见的广告栏的自动 ...
- 什么是CGI、FastCGI、PHP-CGI、PHP-FPM、Spawn-FCGI?
https://mp.weixin.qq.com/s/Co1LxS2h_ILh9syOmshjZg 什么是CGI CGI全称是“公共网关接口”(Common Gateway Interface),HT ...
- vue tab栏缓存解决跳转页面后返回的状态保持
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8& ...
- Project Euler Problem 7-10001st prime
素数线性筛 MAXN = 110100 prime = [0 for i in range(210000)] for i in range(2,MAXN): if prime[i] == 0: pri ...
- 在对文件进行随机读写,RandomAccessFile类,如何提高其效率
花1K内存实现高效I/O的RandomAccessFile类 JAVA的文件随机存取类(RandomAccessFile)的I/O效率较低.通过分析其中原因,提出解决方案.逐步展示如何创建具备缓存读写 ...
- H3C OSI参考模型层次结构
- 如何查看linux中的ssh端口开启状态
netstat -anp |grep 22 netstat -anp |grep sshlsof -i :22
- uni-app学习记录03-路由跳转
<template> <view class="content"> <!-- v-show是相对于display: none --> <v ...