elk日志某个时间节点突然搜索不到了

elk日志某个时间节点突然搜索不到了,检查filebeat正常

Kibana手动上传数据:

响应:

Error:

Validation Failed: 1: this action would add [2] total shards, but this cluster currently has [2000]/[2000] maximum shards open

原因:ElasticSearch总分片数量导致的异常,ES总分片数限制最大只有2000个,目前已经用完了,导致已经没法创建新的索引了。

解决方案:
        解决方法就是提高ES的分片数量。

方法1:控制台

PUT /_cluster/settings
{
  "persistent": {
    "cluster": {
      "max_shards_per_node":10000
    }
  }
}
persistent:永久生效,transient:临时生效。

方法2:CURL命令

curl --location --request PUT 'http://127.0.0.1:9200/_cluster/settings' \
--header 'Content-Type: application/json' \
--data '{"persistent":{"cluster":{"max_shards_per_node":10000}}}'
persistent:永久生效,transient:临时生效。 

查看是否生效
GET /_cluster/settings?pretty

结果

{
    "persistent": {
        "cluster": {
            "max_shards_per_node": "10000"
        }
    },
    "transient": {}
}

删除索引

查询索引

GET _cat/indices

显示索引的文档数

GET http://127.0.0.1:9200/_cat/count/index_name?v

定期清理索引

方式1:利用ES的索引生命周期
方式2:脚本实现(日期后缀索引YYYY.MM.DD)

#!/bin/bash

###################################
#删除早于十天的ES集群的索引
###################################
function delete_indices() {
    comp_date=`date -d "10 day ago" +"%Y-%m-%d"`
    date1="$1 00:00:00"
    date2="$comp_date 00:00:00"

    t1=`date -d "$date1" +%s` 
    t2=`date -d "$date2" +%s` 

    if [ $t1 -le $t2 ]; then
        echo "$1时间早于$comp_date,进行索引删除"
        #转换一下格式,将类似2017-10-01格式转化为2017.10.01
        format_date=`echo $1| sed 's/-/\./g'`
        curl -XDELETE http://es-cluster-ip:9200/*$format_date
    fi
}

curl -XGET http://es-cluster-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

手动删除

修改配置信息为'开启使用通配符或_all'

PUT /_cluster/settings { "transient": { "action.destructive_requires_name": true } }

DELETE /索引名字(可以使用*作为通配符)

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值