集群版本说明:es 7.5.1
REST接口
查看所有_cat接口
curl http://127.0.0.1:9200/_cat?v
查看master节点
curl http://127.0.0.1:9200/_cat/master?v
查看集群健康状态
curl http://127.0.0.1:9200/_cat/health?v
查看节点状态
curl http://127.0.0.1:9200/_cat/nodes?v
查看插件列表
curl http://127.0.0.1:9200/_cat/plugins?v
查看所有索引状态
curl http://127.0.0.1:9200/_cat/indices?v
查看索引分片信息
curl http://127.0.0.1:9200/_cat/shards|grep nginx
查看集群磁盘资源分片信息(重要)
curl http://127.0.0.1:9200/_cat/allocation?v
查看集群索引修复状态(重要)
curl http://127.0.0.1:9200/_cat/recovery?v
curl http://172.25.20.65:9200/_cat/recovery/{index}?v
查看集群健康状态(重要)
curl http://127.0.0.1:9200/_cluster/health
集群资源分配诊断信息(重要)
curl http://127.0.0.1:9200/_cluster/allocation/explain
集群统计信息(重要)
节点统计信息(重要)
http://127.0.0.1:9200/_nodes
http://127.0.0.1:9200/_nodes/stats
http://127.0.0.1:9200/_nodes/es1
通过日期批量删除索引
vim /opt/soft/elk/es/delete-index.sh
#!/bin/bash
# 保留近N天
KEEP_DAYS=30
# 删除前N的所有天到 前N+2天==>每天执行
function get_delete_days()
{
for i in $(seq 1 2);
do
THIS_DAY=$(date -d "$(($KEEP_DAYS+$i)) day ago" +%Y.%m.%d)
DAY_ARR=( "${DAY_ARR[@]}" $THIS_DAY)
done
echo ${DAY_ARR[*]}
}
# 获取日期列表
DELETE_DAYS=(`get_delete_days`)
for day in "${DELETE_DAYS[@]}"
do
echo "delete $day"
#执行删除
curl -XDELETE 'http://127.0.0.1:9200/*-'${day}
done
chmod a+x /opt/soft/elk/es/delete-index.sh
计划任务
crontab -e
30 23 * * 7 /opt/soft/elk/es/delete-index.sh