Skip to content

Commit c63ce41

Browse files
committed
add cluster_update_settings.md
1 parent 00a65f2 commit c63ce41

File tree

3 files changed

+130
-1
lines changed

3 files changed

+130
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ npm run docs:dev
901901
- :heavy_check_mark: 集群重路由 API [:link:](https://elasticsearch.bookhub.techrest_apis/cluster_apis/cluster_reroute)
902902
- :heavy_check_mark: 集群状态 API [:link:](https://elasticsearch.bookhub.techrest_apis/cluster_apis/cluster_state)
903903
- :heavy_check_mark: 集群统计 API [:link:](https://elasticsearch.bookhub.techrest_apis/cluster_apis/cluster_stats)
904-
- Cluster update settings
904+
- :heavy_check_mark: 集群更新设置 API [:link:](https://elasticsearch.bookhub.techrest_apis/cluster_apis/cluster_update_settings)
905905
- Nodes feature usage
906906
- Nodes hot threads
907907
- Nodes info
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# 集群更新设置 API
2+
3+
:::info 新 API 参考
4+
有关最新的 API 详情,请参阅[集群 API](https://www.elastic.co/docs/api/doc/elasticsearch/v8/group/endpoint-cluster)
5+
:::
6+
7+
配置[动态集群设置](/set_up_elasticsearch/configuring_elasticsearch)
8+
9+
## 请求
10+
11+
`PUT /_cluster/settings`
12+
13+
## 前置条件
14+
15+
- 如果启用了 Elasticsearch 安全功能,你必须拥有 `manage` [集群权限](secure_the_elastic_statck/user_authorization/security_privileges#集群权限)才能使用此 API。
16+
17+
## 描述
18+
19+
你可以使用集群更新设置 API 在运行中的集群上配置和更新动态设置。你也可以使用 `elasticsearch.yml` 在未启动或已关闭的节点上本地配置动态设置。
20+
21+
使用集群更新设置 API 进行的更新可以是*持久性*的(在集群重启后仍然有效),也可以是*临时性*的(在集群重启后重置)。你还可以通过使用 API 将临时或持久设置赋值为 `null` 来重置它们。
22+
23+
如果你使用多种方法配置相同的设置,Elasticsearch 会按以下优先级顺序应用设置:
24+
25+
1. 临时设置
26+
2. 持久设置
27+
3. `elasticsearch.yml` 设置
28+
4. 默认设置值
29+
30+
例如,你可以应用临时设置来覆盖持久设置或 `elasticsearch.yml` 设置。但是,对 `elasticsearch.yml` 设置的更改不会覆盖已定义的临时或持久设置。
31+
32+
:::tip 提示
33+
如果你使用 Elasticsearch Service,请使用[用户设置](https://www.elastic.co/docs/deploy-manage/deploy/elastic-cloud/edit-stack-settings)功能来配置所有集群设置。这种方法可以让 Elasticsearch Service 自动拒绝可能破坏集群的不安全设置。
34+
35+
如果你在自己的硬件上运行 Elasticsearch,请使用集群更新设置 API 来配置动态集群设置。仅将 `elasticsearch.yml` 用于静态集群设置和节点设置。API 不需要重启,并确保所有节点上的设置值相同。
36+
:::
37+
38+
:::warning 警告
39+
我们不再推荐使用临时集群设置。请改用持久集群设置。如果集群变得不稳定,临时设置可能会意外清除,导致可能不希望的集群配置。请参阅[临时设置迁移指南](/migration_guide/8.0/transient_settings_migration_guide)
40+
:::
41+
42+
## 查询参数
43+
44+
- `flat_settings`
45+
(可选,布尔值)如果为 `true`,以扁平格式返回设置。默认为 `false`
46+
47+
- `include_defaults`
48+
(可选,布尔值)如果为 `true`,返回所有默认集群设置。默认为 `false`
49+
50+
- `master_timeout`
51+
(可选,[时间单位](/rest_apis/api_convention/common_options.html#时间单位))等待主节点的时间。如果在超时到期前主节点不可用,请求失败并返回错误。默认为 `30s`。也可以设置为 `-1` 表示请求永不超时。
52+
53+
- `timeout`
54+
(可选,[时间单位](/rest_apis/api_convention/common_options.html#时间单位))更新集群元数据后等待集群中所有相关节点响应的时间。如果在超时到期前未收到响应,集群元数据更新仍然适用,但响应将指示未被完全确认。默认为 `30s`。也可以设置为 `-1` 表示请求永不超时。
55+
56+
## 示例
57+
58+
持久性更新示例:
59+
60+
```bash
61+
PUT /_cluster/settings
62+
{
63+
"persistent" : {
64+
"indices.recovery.max_bytes_per_sec" : "50mb"
65+
}
66+
}
67+
```
68+
69+
临时更新示例:
70+
71+
:::warning 警告
72+
我们不再推荐使用临时集群设置。请改用持久集群设置。如果集群变得不稳定,临时设置可能会意外清除,导致可能不希望的集群配置。请参阅[临时设置迁移指南](/migration_guide/8.0/transient_settings_migration_guide)
73+
:::
74+
75+
```bash
76+
PUT /_cluster/settings?flat_settings=true
77+
{
78+
"transient" : {
79+
"indices.recovery.max_bytes_per_sec" : "20mb"
80+
}
81+
}
82+
```
83+
84+
更新后的响应返回更改的设置,如临时示例的响应:
85+
86+
```json
87+
{
88+
...,
89+
"persistent" : { },
90+
"transient" : {
91+
"indices.recovery.max_bytes_per_sec" : "20mb"
92+
}
93+
}
94+
```
95+
96+
重置设置示例:
97+
98+
```bash
99+
PUT /_cluster/settings
100+
{
101+
"transient" : {
102+
"indices.recovery.max_bytes_per_sec" : null
103+
}
104+
}
105+
```
106+
107+
响应不包括已重置的设置:
108+
109+
```json
110+
{
111+
...,
112+
"persistent" : {},
113+
"transient" : {}
114+
}
115+
```
116+
117+
你也可以使用通配符重置设置。例如,重置所有动态 `indices.recovery` 设置:
118+
119+
```bash
120+
PUT /_cluster/settings
121+
{
122+
"transient" : {
123+
"indices.recovery.*" : null
124+
}
125+
}
126+
```
127+
128+
> [原文链接](https://www.elastic.co/guide/en/elasticsearch/reference/8.18/cluster-update-settings.html)

sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ const sidebars = {
178178
"rest_apis/cluster_apis/cluster_reroute",
179179
"rest_apis/cluster_apis/cluster_state",
180180
"rest_apis/cluster_apis/cluster_stats",
181+
"rest_apis/cluster_apis/cluster_update_settings",
181182
],
182183
},
183184
{

0 commit comments

Comments
 (0)