Elasticsearch专题精讲—— REST APIs —— Cluster APIs —— Cluster state API

REST APIs —— Cluster APIs —— Cluster state API

https://www.elastic.co/guide/en/elasticsearch/reference/8.8/cluster-state.html#cluster-state

Returns an internal representation of the cluster state for debugging or diagnostic purposes.

返回用于调试或诊断目的的群集状态的内部表示。

1、Request(请求)

https://www.elastic.co/guide/en/elasticsearch/reference/8.8/cluster-state.html#cluster-state-api-request

        GET /_cluster/state//< target>
    

2、Prerequisites(先决条件)

https://www.elastic.co/guide/en/elasticsearch/reference/8.8/cluster-state.html#cluster-state-api-prereqs

If the Elasticsearch security features are enabled, you must have the manage cluster privilege to use this API.

如果启用了 Elasticsearch 安全特性,则必须拥有管理集群特权才能使用此 API。

3、Description(描述)

https://www.elastic.co/guide/en/elasticsearch/reference/8.8/cluster-state.html#cluster-state-api-desc

The cluster state is an internal data structure which keeps track of a variety of information needed by every node, including:

集群状态是一种内部数据结构,它跟踪每个节点所需的各种信息,包括:

  • The identity and attributes of the other nodes in the cluster.

    集群中其他节点的标识和属性

  • Cluster-wide settings.

    集群中其集群设置

  • Index metadata, including the mapping and settings for each index.

    索引元数据,包括每个索引的映射和设置。

  • The location and status of every shard copy in the cluster.

    集群中每个分片副本的位置和状态。

The elected master node ensures that every node in the cluster has a copy of the same cluster state. The cluster state API lets you retrieve a representation of this internal state for debugging or diagnostic purposes. You may need to consult the Elasticsearch source code to determine the precise meaning of the response.

选举的主节点确保群集中的每个节点都有相同的群集状态副本。群集状态 API 允许您检索该内部状态的表示,以进行调试或诊断目的。您可能需要查阅 Elasticsearch 源代码,以确定响应的精确含义。

By default the cluster state API will route requests to the elected master node since this node is the authoritative source of cluster states. You can also retrieve the cluster state held on the node handling the API request by adding the query parameter ?local=true.

默认情况下,群集状态 API 将路由请求到选举的主节点,因为此节点是群集状态的权威来源。您还可以通过添加查询参数 ?local=true 来检索处理 API 请求的节点上保存的群集状态。

Elasticsearch may need to expend significant effort to compute a response to this API in larger clusters, and the response may comprise a very large quantity of data. If you use this API repeatedly, your cluster may become unstable.

在较大的集群中,Elasticsearch 可能需要花费大量的工作来计算此 API 的响应,并且响应可能包含非常大量的数据。如果您反复使用此 API,则可能导致您的集群不稳定。

4、Examples(例子)

https://www.elastic.co/guide/en/elasticsearch/reference/8.8/cluster-state.html#cluster-state-api-example

The following example returns only metadata and routing_table data for the foo and bar data streams or indices:

以下示例仅返回“foo”和“bar”数据流或索引的元数据和路由分配表数据:

        curl -X GET "localhost:9200/_cluster/state/metadata,routing_table/foo,bar?pretty"
    

The next example returns all available metadata for foo and bar:

下一个示例返回 foo 和 bar 的所有可用元数据:

        curl -X GET "localhost:9200/_cluster/state/_all/foo,bar?pretty"

This example returns only the blocks metadata:

此示例只返回块元数据:

        curl -X GET "localhost:9200/_cluster/state/blocks?pretty"
posted @ 2023-06-24 23:19  左扬  阅读(15)  评论(0编辑  收藏  举报
levels of contents