Elasticsearch履歴データのクリーニング-手動クリーニング
周囲
- esはdockerスタンドアロンスタートアップ、バージョン7.1.1です。
実装する
1.ワイルドカードバッチ削除インデックスをサポートしているかどうかを確認します(false =サポート、true =サポートなし)
curl -X GET "172.168.1.116:9200/_cluster/settings?pretty"
{
"persistent" : {
"action" : {
"destructive_requires_name" : "false"
}
},
"transient" : { }
}
2.trueの場合に実行します
curl -H "Content-Type: application/json" -XPUT '172.168.1.116:9200/_cluster/settings' -d '{"persistent": {"action.destructive_requires_name": "false"}}'
3.すべてのインデックスを表示する
curl -X GET "172.168.1.116:9200/_cat/indices?v"
4. destructive_requires_name = falseを変更した後、次のコマンドを実行します
curl -X DELETE "172.168.1.116:9200/filebeat-7.1.1-2021.02*?pretty"
- 注:172.168.1.116:9200は実際のesアドレスとポートに変更され、 filebeat-7.1.1-2021.02はワイルドカードである実際のインデックス名に変更されます。
試験
- 清理前es目录大小
du -sh elasticsearch/data/
50G elasticsearch/data/
- 清理后es目录大小
du -sh elasticsearch/data/
4.9G elasticsearch/data/
タイミング処理
参照
- https://www.qikegu.com/docs/3063
- https://www.elastic.co/guide/cn/elasticsearch/guide/current/retiring-data.html
- https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html#delete-index-api-path-params
- https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html