Elasticsearch - 集群API

此API用于获取有关群集及其节点的信息并对其进行更改.要调用此API,我们需要指定节点名称,地址或_local.例如,

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

回复

………………………………………………
{
   "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",
      }
   }
}
………………………………………………

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

响应

与上例相同.

群集运行状况

此API用于通过附加运行状况关键字来获取群集运行状况的状态.例如,

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

响应

{
   "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
}

群集状态

此API用于通过附加"state"关键字URL来获取有关群集的状态信息.状态信息包含版本,主节点,其他节点,路由表,元数据和块.例如,

GET http://localhost:9200/_cluster/state 10. Elasticsearch  -  Cluster API

回复

………………………………………………

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

群集统计

此API有助于使用"stats"关键字检索有关群集的统计信息.此API返回分片号,存储大小,内存使用情况,节点数,角色,操作系统和文件系统.例如,

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

回复

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

待定的群集任务

此API用于监控待处理的任务任务就像创建索引,更新映射,分配分片,失败分片等.例如,

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

Cluster Reroute

此API用于将碎片从一个节点移动到另一个节点或取消任何分配或分配任何unassi gned shard.例如,

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

请求正文

{
   "commands" : [ 
      {
         "move" :
         {
            "index" : "schools", "shard" : 2,
            "from_node" : "nodea", "to_node" : "nodeb"
         }
      },
		
      {
         "allocate" : {
            "index" : "test", "shard" : 1, "node" : "nodec"
         }
      }
   ]
}

群集更新设置

此API允许您使用设置关键字更新群集的设置.有两种类型的设置 - 持久(在重新启动时应用)和瞬态(在完整群集重启后无法生存).

节点统计

这API用于检索群集的另一个节点的统计信息.节点统计信息几乎与群集相同.例如,

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

回复

………………………………………………
{
   "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",
      }
   }
}
………………………………………………

节点hot_threads

此API可帮助您检索有关群集中每个节点上当前热线程的信息.例如,

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

回复

………………………………………………
::: {Red Guardian} {Vy3KxqcHQdm4cIM22U1ewA} {127.0.0.1}{127.0.0.1:9300}Hot threads at 
   2016-02-03T10: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
………………………………………………