I am using ES 6.1. and I am trying to change default number of shards from 5 to, for example, 6. Is it possible in some way? When I add lines bellow to the elasticsearch.yaml
file, the ES will not start.
index.number_of_replicas : 1
index.number_of_shards: 6
The error looks like this:
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" }'
My understanding:
If I have no indices or when all indices are closed, i can change default value via :
curl -XPUT 'http://localhost:9200/_all/_settings?preserve_existing=true' -d '{
"index.number_of_replicas" : "1",
"index.number_of_shards" : "6"
}'
Otherwise I am not possible to change default number of shards.
I know I can't change number of shard after indices are created. I can create index like this
curl -XPUT "$(hostname -I):9200/myindex/_settings?pretty" -H 'Content-Type: application/json' -d'
{
"index" : {
"number_of_shards" : 2,
"number_of_replicas" : 0
}
}
'
I am sending data to ES from Logstash, and create indexes automatically with name depends on date and type, so I cannot create every index manually.
My questions are:
It looks like from ES5 there is templates, so when you would like to change this parameters, you have to create your own template and using regex specify which index will use this template. More information here.
I solved this issue via this command:
PUT _template/default
{
"index_patterns": ["*"],
"order": -1,
"settings": {
"number_of_shards": "6",
"number_of_replicas": "1"
}
}
Now, when I create new index, it has 6 shards and 1 replicas.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With