ElasticSearch 集群 API

  • 集群 API

    群集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”关键字来更新集群的设置。设置有两种类型-persistent(在重新启动中应用)和transient(在整个群集重新启动后不起作用)。
  • 节点统计

    此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
    
    运行上面的代码后,我们得到如下所示的响应:
    
    ::: {localhost}{zdKSriXfSP-5urxmdXjN3A}{OI0w21PLSxev_chINWD9mQ}{192.168.61.201}{192.168.61.201:9300}{cdhilmrstw}{ml.machine_memory=3973373952, xpack.installed=true, transform.node=true, ml.max_open_jobs=20}
       Hot threads at 2021-02-02T09:09:08.516Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true:
       
        0.0% (73.2micros out of 500ms) cpu usage by thread 'ticker-schedule-trigger-engine'
         10/10 snapshots sharing following 2 elements
           java.lang.Thread.sleep(Native Method)
           org.elasticsearch.xpack.watcher.trigger.schedule.engine.TickerScheduleTriggerEngine$Ticker.run(TickerScheduleTriggerEngine.java:193)