删除elasticsearch数据
删除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