gpt4 book ai didi

elasticsearch - ES-6 .1。 - 如何更改默认的碎片数量

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

我正在使用 ES 6.1。我正在尝试将默认的分片数量从 5 更改为例如 6。是否有可能以某种方式实现?当我将下面的行添加到 elasticsearch.yaml 文件时,ES 将不会启动。

index.number_of_replicas : 1
index.number_of_shards: 6

错误看起来像这样:

Found index level settings on node level configuration.

Since elasticsearch 5.x index level settings can NOT be set on the nodes configuration like the elasticsearch.yaml, in system properties or command line arguments.In order to upgrade all indices the settings must be updated via the /${index}/_settings API. Unless all settings are dynamic all indices must be closed in order to apply the upgradeIndices created in the future should use index templates to set default values.

Please ensure all required values are updated on all indices by executing:

curl -XPUT 'http://localhost:9200/_all/_settings?preserve_existing=true' -d '{ "index.number_of_replicas" : "1", "index.number_of_shards" : "6" }'

我的理解:
如果我没有索引或者当所有索引都关闭时,我可以通过以下方式更改默认值:

curl -XPUT 'http://localhost:9200/_all/_settings?preserve_existing=true' -d '{
"index.number_of_replicas" : "1",
"index.number_of_shards" : "6"
}'

否则我无法更改默认的分片数量。

我知道在创建索引后我无法更改分片数量。我可以这样创建索引

curl -XPUT  "$(hostname -I):9200/myindex/_settings?pretty" -H 'Content-Type: application/json' -d'
{
"index" : {
"number_of_shards" : 2,
"number_of_replicas" : 0
}
}
'

我正在从 Logstash 向 ES 发送数据,并根据日期和类型自动创建名称的索引,因此我无法手动创建每个索引。

我的问题是:

  1. 有什么办法可以改变默认的分片数量吗?如果是,如何?
  2. 我可以有不同数量的分片的不同索引吗?

最佳答案

看起来 ES5 中有模板,所以当您想更改此参数时,您必须创建自己的模板并使用正则表达式指定哪个索引将使用此模板。更多信息 here .

我通过这个命令解决了这个问题:

PUT _template/default
{
"index_patterns": ["*"],
"order": -1,
"settings": {
"number_of_shards": "6",
"number_of_replicas": "1"
}
}

现在,当我创建新索引时,它有 6 个分片和 1 个副本。

关于elasticsearch - ES-6 .1。 - 如何更改默认的碎片数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48559563/

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