Why all new Indexes start with 5 replicas?

Hi,

All my indexes start with 5 indexes when they are created this results in my status running yellow, since I do not run a cluster.

In order to fix this, I always run manually this:

PUT /logstash-2018*/_settings
{
 "index": {
   "number_of_replicas": 0
  }
}’

GET /_cluster/allocation/explain?pretty=true

}’

First I query with GET and change with PUT.

How can I make all indexes to start with 0 replicas?

You can change the default by adding the following to elasticsearch.yml:
index.number_of_replicas: 0

After doing so, I got 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" : "0"
}'
*************************************************************************************

[2018-08-16T23:45:59,268][ERROR][o.e.b.Bootstrap          ] Exception
java.lang.IllegalArgumentException: node settings must not contain any index level settings
	at org.elasticsearch.common.settings.SettingsModule.<init>(SettingsModule.java:129) ~[elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.node.Node.<init>(Node.java:339) ~[elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.node.Node.<init>(Node.java:252) ~[elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:213) ~[elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:213) ~[elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:326) [elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) [elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) [elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) [elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) [elasticsearch-cli-6.3.2.jar:6.3.2]
	at org.elasticsearch.cli.Command.main(Command.java:90) [elasticsearch-cli-6.3.2.jar:6.3.2]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) [elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) [elasticsearch-6.3.2.jar:6.3.2]
[2018-08-16T23:45:59,285][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalArgumentException: node settings must not contain any index level settings
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:140) ~[elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.3.2.jar:6.3.2]
	at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.3.2.jar:6.3.2]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.3.2.jar:6.3.2]
Caused by: java.lang.IllegalArgumentException: node settings must not contain any index level settings
	at org.elasticsearch.common.settings.SettingsModule.<init>(SettingsModule.java:129) ~[elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.node.Node.<init>(Node.java:339) ~[elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.node.Node.<init>(Node.java:252) ~[elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:213) ~[elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:213) ~[elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:326) ~[elasticsearch-6.3.2.jar:6.3.2]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-6.3.2.jar:6.3.2]
	... 6 more

After reverting back to initial config I get this log

Elasticlog

try this
"number_of_replicas": "0"

The best way to pre-define the number of primary or replica shards is through the Index Template mechanism, which may define both static and dynamic index settings as well as field mappings. An index template is automatically applied by Elasticsearch when creating a new index with a name matching the index_patterns of the template.

For logstash-2018* indices something like this should work:

curl -X PUT "localhost:9200/_template/logstash_templ" -H 'Content-Type: application/json' -d'
{
  "index_patterns": ["logstash*"],
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0
  }
}
'

Notice that I've set number of (primary) shards to 1 since that is usually sufficient for the daily logstash indices (optimal shard size is typically form 20-50 GB).

1 Like

Yeah my bad, as of Elasticsearch v5.x index level settings can not be set on node configs like the Elasticsearch.yaml.

You next good bet would be to use index templates as see here.

This returned:
{
"acknowledged": true
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.