鍍金池/ 教程/ Java/ Elasticsearch集群API
Elasticsearch搜索API
Elasticsearch教程
Elasticsearch填充
Elasticsearch測(cè)試
Elasticsearch分析
Elasticsearch映射
Elasticsearch入門教程
Elasticsearch版本之間遷移
Elasticsearch集群API
Elasticsearch模塊
Elasticsearch環(huán)境安裝配置
Elasticsearch聚合
Elasticsearch查詢DSL
Elasticsearch索引API
Elasticsearch API約定
Elasticsearch文檔API

Elasticsearch集群API

此API用于獲取有關(guān)集群及其節(jié)點(diǎn)的信息,并對(duì)其進(jìn)行更改。 對(duì)于調(diào)用此API,需要指定節(jié)點(diǎn)名稱,地址或_local。 例如,

GET http://localhost:9200/_nodes/_local

或者

Get http://localhost:9200/_nodes/127.0.0.1

響應(yīng)

... ...
{
   "cluster_name":"elasticsearch", "nodes":{
      "Vy3KxqcHQdm4cIM22U1ewA":{
         "name":"Red Guardian", "transport_address":"127.0.0.1:9300", 
         "host":"127.0.0.1", "ip":"127.0.0.1", "version":"2.1.1", 
         "build":"40e2c53", "http_address":"127.0.0.1:9200",
      }
   }
}
... ...

集群運(yùn)行狀況

此API用于通過追加health關(guān)鍵字來獲取集群運(yùn)行狀況的狀態(tài)。 例如,

GET http://localhost:9200/_cluster/health

響應(yīng)

{
   "cluster_name":"elasticsearch", "status":"yellow", "timed_out":false,
   "number_of_nodes":1, "number_of_data_nodes":1, "active_primary_shards":23,
   "active_shards":23, "relocating_shards":0, "initializing_shards":0,
   "unassigned_shards":23, "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
}

集群狀態(tài)

此API用于通過附加’state‘關(guān)鍵字URL來獲取有關(guān)集群的狀態(tài)信息。狀態(tài)信息包含:版本,主節(jié)點(diǎn),其他節(jié)點(diǎn),路由表,元數(shù)據(jù)和塊。 例如,

GET http://localhost:9200/_cluster/state 10. Elasticsearch — Cluster APIs

響應(yīng)

{
   "cluster_name":"elasticsearch", "version":27, "state_uuid":"B3P7uHGKQUGsSsiX2rGYUQ",
   "master_node":"Vy3KxqcHQdm4cIM22U1ewA",

}

群集統(tǒng)計(jì)信息

此API有助于使用’stats‘關(guān)鍵字檢索有關(guān)集群的統(tǒng)計(jì)信息。 此API返回碎片編號(hào),存儲(chǔ)大小,內(nèi)存使用情況,節(jié)點(diǎn)數(shù),角色,操作系統(tǒng)和文件系統(tǒng)。 例如,

GET http://localhost:9200/_cluster/stats

響應(yīng)

{
   "timestamp":1454496710020, "cluster_name":"elasticsearch", "status":"yellow",
   "indices":{
      "count":5, "shards":{
         "total":23, "primaries":23, "replication":0.0,"
      }
   }
}

正在等待的群集任務(wù)

此API用于監(jiān)視任何集群中的掛起任務(wù)。任務(wù)類似于創(chuàng)建索引,更新映射,分配碎片,故障碎片等。例如,

GET http://localhost:9200/_cluster/pending_tasks

集群重新路由

此API用于將分片從一個(gè)節(jié)點(diǎn)移動(dòng)到另一個(gè)節(jié)點(diǎn),或者用于取消任何分配或分配任何未分配的碎片。 例如,

POST http://localhost:9200/_cluster/reroute

請(qǐng)求正文

{
   "commands" : [ 
      {
         "move" :
         {
            "index" : "schools", "shard" : 2,
            "from_node" : "nodea", "to_node" : "nodeb"
         }
      },

      {
         "allocate" : {
            "index" : "test", "shard" : 1, "node" : "nodec"
         }
      }
   ]
}

群集更新設(shè)置

此API允許使用settings關(guān)鍵字更新群集的設(shè)置。有兩種類型的設(shè)置 - persistent(在重新啟動(dòng)時(shí)應(yīng)用)和transient(在完全群集重新啟動(dòng)后不會(huì)生存)。

節(jié)點(diǎn)統(tǒng)計(jì)

此API用于檢索集群的一個(gè)節(jié)點(diǎn)的統(tǒng)計(jì)信息。節(jié)點(diǎn)狀態(tài)與集群幾乎相同。 例如,

GET http://localhost:9200/_nodes/stats

響應(yīng)

{
   "cluster_name":"elasticsearch", "nodes":{
      "Vy3KxqcHQdm4cIM22U1ewA":{
         "timestamp":1454497097572, "name":"Red Guardian", 
         "transport_address":"127.0.0.1:9300", "host":"127.0.0.1", "ip":["127.0.0.1:9300",
      }
   }
}

節(jié)點(diǎn)hot_threads

此API可用于檢索有關(guān)集群中每個(gè)節(jié)點(diǎn)上當(dāng)前熱線程的信息。 例如,

GET http://localhost:9200/_nodes/hot_threads

響應(yīng)

{Red Guardian} {Vy3KxqcHQdm4cIM22U1ewA} {127.0.0.1}{127.0.0.1:9300}Hot threads at 
   2017-02-01T10:59:48.856Z, interval = 500ms, busiestThreads = 3, 
   ignoreIdleThreads = true:0.0% (0s out of 500ms) cpu usage by thread 'Attach Listener'
      unique snapshot
      unique snapshot