教程 > elastic search > 阅读:28

elasticsearch 集群 cluster api——迹忆客-ag捕鱼王app官网

集群 api 用于获取有关集群及其节点的信息并在其中进行更改。 要调用此 api,我们需要指定节点名称、地址或 _local

get /_nodes/_local

运行上面的代码,我们得到如下所示的响应

………………………………………………
cluster_name" : "elasticsearch",
   "nodes" : {
      "fkh-5blytjmff2rj_lqocg" : {
         "name" : "ubuntu",
         "transport_address" : "127.0.0.1:9300",
         "host" : "127.0.0.1",
         "ip" : "127.0.0.1",
         "version" : "7.0.0",
         "build_flavor" : "default",
         "build_type" : "tar",
         "build_hash" : "b7e28a7",
         "total_indexing_buffer" : 106502553,
         "roles" : [
            "master",
            "data",
            "ingest"
         ],
         "attributes" : {
………………………………………………

集群健康

此 api 用于通过附加“health”关键字来获取集群的健康状态。

get /_cluster/health

在运行上面的代码时,我们得到如下所示的响应

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

集群状态

此 api 用于通过附加“state”关键字 url 来获取有关集群的状态信息。 状态信息包含版本、主节点、其他节点、路由表、元数据和块。

get /_cluster/state

运行上面的代码,我们得到如下所示的响应

………………………………………………
{
   "cluster_name" : "elasticsearch",
   "cluster_uuid" : "izku0oovtq6lxqonjnn2eq",
   "version" : 89,
   "state_uuid" : "y3blwvspr1euqbto0abjig",
   "master_node" : "fkh-5blytjmff2rj_lqocg",
   "blocks" : { },
   "nodes" : {
      "fkh-5blytjmff2rj_lqocg" : {
      "name" : "ubuntu",
      "ephemeral_id" : "426ktgpitgixhezam-5qyg",
      "transport
   }
………………………………………………

集群统计

此 api 通过使用“stats”关键字帮助检索有关集群的统计信息。 此 api 返回分片号、存储大小、内存使用情况、节点数、角色、操作系统和文件系统。

get /_cluster/stats

运行上面的代码,我们得到如下所示的响应

………………………………………….
"cluster_name" : "elasticsearch",
"cluster_uuid" : "izku0oovtq6lxqonjnn2eq",
"timestamp" : 1556435464704,
"status" : "yellow",
"indices" : {
   "count" : 7,
   "shards" : {
      "total" : 7,
      "primaries" : 7,
      "replication" : 0.0,
      "index" : {
         "shards" : {
         "min" : 1,
         "max" : 1,
         "avg" : 1.0
      },
      "primaries" : {
         "min" : 1,
         "max" : 1,
         "avg" : 1.0
      },
      "replication" : {
         "min" : 0.0,
         "max" : 0.0,
         "avg" : 0.0
      }
………………………………………….

集群更新设置

此 api 允许我们使用“settings”关键字更新集群的设置。 有两种类型的设置 - 持久性(跨重启应用)和瞬态(不在整个集群重启后幸存)。


节点统计

此 api 用于检索集群的一个或多个节点的统计信息。 节点统计几乎与集群相同。

get /_nodes/stats

运行上面的代码,我们得到如下所示的响应

{
   "_nodes" : {
      "total" : 1,
      "successful" : 1,
      "failed" : 0
   },
   "cluster_name" : "elasticsearch",
   "nodes" : {
      "fkh-5blytjmff2rj_lqocg" : {
         "timestamp" : 1556437348653,
         "name" : "ubuntu",
         "transport_address" : "127.0.0.1:9300",
         "host" : "127.0.0.1",
         "ip" : "127.0.0.1:9300",
         "roles" : [
            "master",
            "data",
            "ingest"
         ],
         "attributes" : {
            "ml.machine_memory" : "4112797696",
            "xpack.installed" : "true",
            "ml.max_open_jobs" : "20"
         },
………………………………………………………….

节点 hot_threads

此 api 可帮助我们检索有关集群中每个节点上当前热线程的信息。

get /_nodes/hot_threads

运行上面的代码,我们得到如下所示的响应

:::{ubuntu}{fkh-5blytjmff2rj_lqocg}{426ktgpitgixhezam5qyg}{127.0.0.1}{127.0.0.1:9300}{ml.machine_memory=4112797696,
xpack.installed=true, ml.max_open_jobs=20}
 hot threads at 2019-04-28t07:43:58.265z, interval=500ms, busiestthreads=3,
ignoreidlethreads=true:

查看笔记

扫码一下
查看教程更方便
网站地图