dracoblue.net

Local Elasticsearch Cluster Status = RED

If you want to check the status of your local single node elasticsearch development server, you can query the cluster stats endpoint at maybe http://localhost:9200/_cluster/health?level=indices.

{
  "cluster_name": "erstmal",
  "status": "red",
  "number_of_nodes": 1,
  "assigned_shards": 4,
  "unassigned_shards": 126
}

If this status shows "red" and you can see lots of unassigned_shards here, you have a problem.

In my case I was running a local elasticsearch instance with no cluster mode at all. But the default configuration of my elasticsearch server was to run with 5 shards and 1 replica.

To fix this, add:

index.number_of_shards: 1
index.number_of_replicas: 0

to your elasticsearch.yml.

If you restart elasticsearch (service elasticsearch restart) all new indices, will have this configuration. But you need to fix this for all existing indicies.

Run:

$ curl -XPUT 'localhost:9200/_settings' -d '{"index.number_of_replicas": 0}'

and all indicies will be updated.

Now calling http://localhost:9200/_cluster/health?level=indices should give:

{
  "cluster_name": "erstmal",
  "status": "green",
  "timed_out": false,
  "number_of_nodes": 1,
  "assigned_shards": 130,
  "unssigned_shards": 0
}

after some minutes.

Of course there are plenty of other reasons why the cluster status of elasticsearch might change from green to yellow or red. See for example chris simpsons post for more information.

In elasticsearch, open source by
@ 31 Jan 2016, Comments at Reddit & Hackernews

Give something back

Were my blog posts useful to you? If you want to give back, support one of these charities, too!

Report hate in social media Campact e.V. With our technology and your help, we protect the oceans from plastic waste. Gesellschaft fur Freiheitsrechte e. V. The civil eye in the mediterranean

Recent Dev-Articles

Read recently

Recent Files

About