dor*_*and 4 configuration elasticsearch
我使用的是ES 6.1.我试图将默认的分片数从5改为,例如,6.是否有可能以某种方式?当我在elasticsearch.yaml文件下面添加行时,ES将无法启动.
index.number_of_replicas : 1
index.number_of_shards: 6
Run Code Online (Sandbox Code Playgroud)
错误如下所示:
在节点级配置上找到索引级别设置.
由于elasticsearch 5.x索引级别设置不能在诸如elasticsearch.yaml之类的节点配置中设置,在系统属性或命令行参数中.为了升级所有索引,必须通过/ $ {index}/_设置更新设置API.除非所有设置都是动态的,否则必须关闭所有索引才能应用将来创建的upgradeIndices应使用索引模板来设置默认值.
请确保通过执行以下内容更新所有索引的所有必需值:
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"
}'
Run Code Online (Sandbox Code Playgroud)
否则我无法更改默认的分片数.
我知道在创建索引后我无法更改分片数.我可以像这样创建索引
curl -XPUT "$(hostname -I):9200/myindex/_settings?pretty" -H 'Content-Type: application/json' -d'
{
"index" : {
"number_of_shards" : 2,
"number_of_replicas" : 0
}
}
'
Run Code Online (Sandbox Code Playgroud)
我正在从Logstash向ES发送数据,并自动创建索引,名称取决于日期和类型,因此我无法手动创建每个索引.
我的问题是:
从ES5看起来有模板,因此当您想要更改此参数时,您必须创建自己的模板并使用正则表达式指定哪个索引将使用此模板.更多信息在这里.
我通过这个命令解决了这个问题:
PUT _template/default
{
"index_patterns": ["*"],
"order": -1,
"settings": {
"number_of_shards": "6",
"number_of_replicas": "1"
}
}
Run Code Online (Sandbox Code Playgroud)
现在,当我创建新索引时,它有6个分片和1个副本.
| 归档时间: |
|
| 查看次数: |
2662 次 |
| 最近记录: |