集群更新设置
可通过kibana/cerebro执行GET查询获取当前集群的settings
GET /_cluster/settings
集群未做任何设置时执行查询响应如下:
{
"persistent": {},
"transient": {}
}
允许更新集群范围内的特定设置。更新的设置可以是persistent 持久性的(重启后依旧有效),也可以是 transient 临时性的(完全重启集群后失效)。
PUT /_cluster/settings
{
"persistent" : {
"indices.recovery.max_bytes_per_sec" : "50mb"
}
}
Or:
PUT /_cluster/settings?flat_settings=true
{
"transient" : {
"indices.recovery.max_bytes_per_sec" : "20mb"
}
}
当你依次执行上面transient的设置后,响应如下:
{
"acknowledged": true,
"persistent": {},
"transient": {
"indices": {
"recovery": {
"max_bytes_per_sec": "20mb"
}
}
}
}
此时执行get查询响应如下:
{
"persistent": {
"indices": {
"recovery": {
"max_bytes_per_sec": "50mb"
}
}
},
"transient": {
"indices": {
"recovery": {
"max_bytes_per_sec": "20mb"
}
}
}
}
可以通过设置null值来重置persistent持久性或transient瞬态设置。如果重置了瞬态设置为null,则在可用时应用持久设置(之前设置的persistent将被使用)。否则,Elasticsearch将回退到配置文件中定义的设置,或者,如果不存在,回退到默认值。如:
PUT /_cluster/settings?flat_settings=true
{
"transient" : {
"indices.recovery.max_bytes_per_sec" : null
}
}
响应如下:
{
"acknowledged": true,
"persistent": {},
"transient": {}
}
当你再次执行: GET /_cluster/settings
响应如下:
{
"persistent": {
"indices": {
"recovery": {
"max_bytes_per_sec": "50mb"
}
}
},
"transient": {}
}
还可以使用简单的通配符重置设置。以下以indices.recovery为前缀的所有transient配置设置为null:
PUT /_cluster/settings
{
"transient" : {
"indices.recovery.*" : null
}
}
总结:transient > persistent > elasticsearch.yml
集群临时配 优先于 持久性配置 优先于 配置文件中的配置