刪除elasticsearch資料分為兩種:一種是刪除索引(資料和表結構同時刪除,作用同sql server 中 drop table "表格名"),另一種是刪除資料(不刪除表結構,作用同 sql server中delete 語句)
1、查詢索引
curl -XGET http://127.0.0.1:9201/_cat/indices?v
curl -u user:passwd -XGET http://127.0.0.1:9201/_cat/indices?v
curl -XGET 'http://127.0.0.1:9201/_cat/indices' |awk '{print $3}' | awk -F'-' '{print $1}' |sort |uniq -c
得出佔空間較大的索引的名稱:
sw_log-20240609
sw_log-20240608
sw_log-20240607
sw_segment-20240610
sw_segment-20240611
sw_segment-20240609
sw_segment-20240608
sw_segment-20240607
sw_segment-20240606
2、手工刪除
curl -XDELETE http://127.0.0.1:9201/sw_log-20240607
curl -XDELETE http://127.0.0.1:9201/sw_log-20240608
curl -XDELETE http://127.0.0.1:9201/sw_log-20240609
curl -XDELETE http://127.0.0.1:9201/sw_segment-20240606
curl -XDELETE http://127.0.0.1:9201/sw_segment-20240607
curl -XDELETE http://127.0.0.1:9201/sw_segment-20240608
curl -XDELETE http://127.0.0.1:9201/sw_segment-20240609
curl -XDELETE http://127.0.0.1:9201/sw_segment-20240610
curl -XDELETE http://127.0.0.1:9201/sw_segment-20240611