elasticsearch基本接口使用


一、查看當前es上的所有索引

curl -XGET "http://127.0.0.1:9200/_cat/indices"      # 查看索引縮略信息

curl -XGET "http://127.0.0.1:9200/_cat/indices?v"        # 查看索引詳細信息

 

二、查看elasticsearch集群狀態

curl -sXGET "http://127.0.0.1:9200/_cluster/health?pretty"

{ "cluster_name" : "elasticone", "status" : "yellow", "timed_out" : false, "number_of_nodes" : 1, "number_of_data_nodes" : 1, "active_primary_shards" : 541, "active_shards" : 541, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 541, "delayed_unassigned_shards" : 0, "number_of_pending_tasks" : 0, "number_of_in_flight_fetch" : 0, "task_max_waiting_in_queue_millis" : 0, "active_shards_percent_as_number" : 50.0 }
View Code

 

三、查看集群節點信息

curl -XGET "http://127.0.0.1:9200/_cat/nodes?v"

 

四、查看節點進程信息

curl -XGET "http://127.0.0.1:9200/_nodes/process?pretty"

 

五、查看索引統計信息

curl -XGET "http://127.0.0.1:9200/_stats?pretty"

 

六、查看指定索引統計信息

curl -XGET "http://127.0.0.1:9200/索引名/_stats?pretty"

curl -XGET "http://127.0.0.1:9200/logstash-2018.10.21/_stats?pretty"

 

七、查看熱點線程

curl -XGET "http://127.0.0.1:9200/_nodes/hot_threads?pretty"

 

八、查看指定索引信息

curl -XGET "http://127.0.0.1:9200/索引名/_mapping?pretty"

curl -XGET "http://127.0.0.1:9200/logstash-2018.10.21/_mapping?pretty"

 

九、查看所有節點jvm信息

curl -XGET "http://127.0.0.1:9200/_nodes/stats/jvm?pretty" 

 

十、查看指定節點jvm信息

curl -XGET "http://127.0.0.1:9200/_nodes/節點名/stats/jvm?pretty"

curl -XGET "http://127.0.0.1:9200/_nodes/searchnode-01/stats/jvm?pretty"

 

十一、刪除全部索引

curl -XDELETE "http://127.0.0.1:9200/*?pretty" 

 

十二、刪除指定索引

curl -XDELETE "http://127.0.0.1:9200/索引名?pretty"

curl -XDELETE "http://127.0.0.1:9200/logstash-2018.10.19?pretty"

 curl -XDELETE "http://127.0.0.1:9200/logstash-2018.10.19?pretty" { "acknowledged" : true }
# 刪除歷史索引思路 

# step1 取出要刪除的索引名 
curl -sXGET "http://127.0.0.1:9200/_cat/indices"|awk '{print $3}'|grep 2018.10    # 2018.10月的所有索引

# step2 使用for循環調用接口刪除之 
for i in `curl -sXGET "http://127.0.0.1:9200/_cat/indices"|awk '{print $3}'|grep 2018.10`;do curl -XDELETE "http://127.0.0.1:9200/$i?pretty";done 

 

十三、查看線程池配置

curl -XGET "http://127.0.0.1:9200/_nodes/thread_pool/"  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM