查看所有的索引文件:
curl -XGET http://localhost:9200/_cat/indices?v
刪除索引文件以釋放空間:
curl -XDELETE http://localhost:9200/filebeat-2016.12.28
單節(jié)點的elk可在索引目錄刪除索引文件:集群環(huán)境刪除某節(jié)點的索引文件,會導致集群服務(wù)不可用.集群環(huán)境需要使用API的方式進行刪除.
索引文件保留在服務(wù)器中,大大減小服務(wù)器的性能,占用硬盤空間,
因此使用腳本自動刪除elk中兩個月以前的索引以釋放空間:
--#!/bin/bash
find '/data/elasticsearch/data/elks/nodes/0/indices/' -name 'filebeat-*' -ctime +60 > index.txt
cd ~
cat index.txt | while read line
do
curl -XDELETE "http://localhost:9200/"$(basename $line)""
done
添加計劃任務(wù):
$crontab -e
0 0 * * * cd /root && ./elk_index_remove.sh >>/dev/null