gpt4 book ai didi

elasticsearch - 更新新索引的默认索引 number_of_replicas 设置

转载 作者:行者123 更新时间:2023-11-29 02:44:46 51 4
gpt4 key购买 nike

根据 documentation,我尝试按如下方式更新副本数

curl -XPUT 'localhost:9200/_settings' -d '
{ "index" : { "number_of_replicas" : 4 } }'

这正确地更改了现有节点的副本数。但是,当 logstash 第二天创建新索引时,number_of_replicas 设置为旧值。

有没有办法永久更改此设置的默认值,而无需更新集群中的所有 elasticsearch.yml 文件并重新启动服务?

我也试过

curl -XPUT 'localhost:9200/logstash-*/_settings' -d '
{ "index" : { "number_of_replicas" : 4 } }'

没用。

最佳答案

是的,您可以使用索引模板。索引模板是为集群中创建的新索引设置默认设置(包括映射)的好方法。

Index Templates

Index templates allow to define templates that will automatically be applied to new indices created. The templates include both settings and mappings, and a simple pattern template that controls if the template will be applied to the index created.

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html

以你的例子为例:

curl -XPUT 'localhost:9200/_template/logstash_template' -d ' 
{
"template" : "logstash-*",
"settings" : {"number_of_replicas" : 4 }
} '

这会将与名称“logstash-*”匹配的所有新索引的默认副本数设置为 4。请注意,这不会更改现有索引,只会更改新创建的索引。

关于elasticsearch - 更新新索引的默认索引 number_of_replicas 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24553718/

51 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com