zoukankan      html  css  js  c++  java
  • es删除索引

    批量删

    配置文件:action.destructive_requires_name true(不能批量删除)  false(可以批量删)

    DATA=`date -d "2 week ago" +%Y.%m.%d`
    curl --user elastic:pass  -XDELETE http://IP:9200/*-${DATA}

    单个删

    curl --user elastic:pss  -XDELETE http://ip:9200/$line$format_date

    #!/bin/bash
    source /etc/profile
    #定义删除30天以前的函数
    delete_indices(){
    check_day=`date -d '-15 days' '+%F'`
    index_day=$1
    #将日期转换为时间戳
    check_day_timestamp=`date -d "$check_day" +%s`
    index_day_timestamp=`date -d "$index_day" +%s`
    #当索引的时间戳值小于当前日期30天前的时间戳时,删除此索引
    if [ ${index_day_timestamp} -lt ${check_day_timestamp} ];then
    #转换日期格式
    format_date=`echo $1 | sed 's/-/./g'`
    while read line
    curl --user elastic:pass  -XDELETE http://IP:9200/$line$format_date
    done<test
    fi
    }
    curl --user elastic:pass -XGET http://IP:9200/_cat/indices | awk -F" " '{print $3}' | awk -F"-" '{print $NF}' | egrep "[0-9]*.[0-9]*.[0-9]*" | sort | uniq | sed 's/./-/g' | while read LINE
    do
    #调用索引删除函数
    delete_indices $LINE
    done

     
  • 相关阅读:
    ASP.NET MVC4 Web 编程第三章
    ASP.NET MVC4 Web 编程第二章
    2020.08.25日
    ASP.NET MVC4 Web 编程第一章
    .net你必须知道的事儿 2.2
    .net你必须知道的事儿 2.1
    资本论
    Cent os mysql主从同步问题
    apache启动脚本
    zentao(禅道)迁移
  • 原文地址:https://www.cnblogs.com/sqbk/p/15205245.html
Copyright © 2011-2022 走看看