ES 集群清除索引 shell 脚本
2017-02-28 17:45
393 查看
ES 集群清除索引 Index 脚本,每个索引格式 "*-YYYY-mm-dd" ,输入截止Unix时间戳。
首先通过 indies 接口获取所有索引,然后遍历判断时间是否小于输入的 Unix 时间戳,是则执行删除索引。
首先通过 indies 接口获取所有索引,然后遍历判断时间是否小于输入的 Unix 时间戳,是则执行删除索引。
#!/bin/bash ip='192.168.1.1' port=9200 endUnixTime=$1 indices=`curl -XGET "http://${ip}:${port}/_cat/indices" | awk '{print $3}'` for index in ${indices[*]} do indexTime=${index##*-} year=`echo ${indexTime} | cut -d "." -f1` month=`echo ${indexTime} | cut -d "." -f2` day=`echo ${indexTime} | cut -d "." -f3` if [ ! $day ] then echo "ignore index:$index" continue fi indexUnixTime=`date -d "$year$month$day" +%s` if [ $indexUnixTime -lt $endUnixTime ] then echo "Delete index:$index" curl -XDELETE "http://${ip}:${port}/$index" fi done
相关文章推荐
- 用SHELL脚本精准清除Squid缓存[更新版] 推荐
- Shell脚本定时备份清除运行系统日志的代码
- shell 脚本实--集群环境配置检测
- 使用shell脚本实现自动化部署HBASE集群
- Shell 脚本 更换tomcat集群war包
- mongodb集群脚本工具(shell)
- Shell脚本监控Storm集群,邮件报警
- hadoop集群机架感应配置的简单过程(shell脚本版本)
- shell 脚本实战笔记(10)--spark集群脚本片段念念碎
- Shell脚本实现精准清除Squid缓存
- MySQL被慢sql hang住了,用shell脚本快速清除不断增长的慢sql的办法
- 用SHELL脚本精准清除Squid缓存
- shell 脚本之清除日志记录
- 通过rsync清除目录的shell脚本
- shell 脚本实战笔记(3)--集群机器的时间同步设置
- 通过rsync清除目录的shell脚本
- 使用Shell脚本批量清除Nginx缓存
- 【甘道夫】Hadoop2.2.0集群启动和停止Shell脚本
- Oracle重建索引Shell脚本、SQL脚本分享
- Shell脚本实现精准清除Squid缓存