Elasticsearch专题精讲—— REST APIs —— Cluster APIs —— Cluster update settings API

REST APIs —— Cluster APIs —— Cluster update settings API

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

Configures dynamic cluster settings.

配置动态群集设置。

1、Request(请求)

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

        PUT /_cluster/settings

2、Prerequisites(先决条件)

https://www.elastic.co/guide/en/elasticsearch/reference/8.8/cluster-update-settings.html#cluster-update-settings-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-update-settings.html#cluster-update-settings-api-desc

You can configure and update dynamic settings on a running cluster using the cluster update settings API. You can also configure dynamic settings locally on an unstarted or shut down node using elasticsearch.yml.

可以使用群集更新设置API在运行中的群集上配置和更新动态设置。您还可以在未启动或关闭的节点上使用elasticsearch.yml本地配置动态设置。

Updates made using the cluster update settings API can be persistent, which apply across cluster restarts, or transient, which reset after a cluster restart. You can also reset transient or persistent settings by assigning them a null value using the API.

使用群集更新设置API进行的更新可以是持久的,在群集重新启动时应用,或者是瞬态的,在群集重新启动后重置。您还可以使用API将瞬态或持久性设置重置为null值。

  1. Transient setting 临时设置
  2. Persistent setting 持久性设置
  3. elasticsearch.yml setting
  4. Default setting value 默认设置值

For example, you can apply a transient setting to override a persistent setting or elasticsearch.yml setting. However, a change to an elasticsearch.yml setting will not override a defined transient or persistent setting.

例如,可以应用一个临时设置来覆盖持久设置或 elasticsearch.yml 设置。但是,对 elasticsearch.yml 设置的更改不会覆盖已定义的临时或持久设置。

4、Examples(例子)

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

An example of a persistent update:

持久更新的一个例子。

curl -X PUT "localhost:9200/_cluster/settings?pretty" -H 'Content-Type: application/json' -d'
        {
          "persistent" : {
            "indices.recovery.max_bytes_per_sec" : "50mb"
          }
        }'

An example of a transient update:

一个临时更新的例子:

curl -X PUT "localhost:9200/_cluster/settings?flat_settings=true&pretty" -H 'Content-Type: application/json' -d'
        {
          "transient" : {
            "indices.recovery.max_bytes_per_sec" : "20mb"
          }
        }'

The response to an update returns the changed setting, as in this response to the transient example:

对更新的响应返回更改后的设置,如对临时示例的响应所示:

        {
            ...
            "persistent" : { },
            "transient" : {
              "indices.recovery.max_bytes_per_sec" : "20mb"
            }
          }

This example resets a setting:

这个例子重置了一个设置:

        curl -X PUT "localhost:9200/_cluster/settings?pretty" -H 'Content-Type: application/json' -d'
        {
          "transient" : {
            "indices.recovery.max_bytes_per_sec" : null
          }
        }'

The response does not include settings that have been reset:

响应不包括已重置的设置:

        {
            ...
            "persistent" : {},
            "transient" : {}
          }

You can also reset settings using wildcards. For example, to reset all dynamic indices.recovery settings:

您还可以使用通配符重置设置。例如,重置所有动态 indexes.Recovery 设置:

curl -X PUT "localhost:9200/_cluster/settings?pretty" -H 'Content-Type: application/json' -d'
        {
          "transient" : {
            "indices.recovery.*" : null
          }
        }'
posted @ 2023-06-24 23:47  左扬  阅读(43)  评论(0编辑  收藏  举报
levels of contents