ElasticSearch status is yellow (Unassigned Shards)


(Aditya Patel) #1

Hi

My current Elasticsearch on querying for cluster health is "yellow"
curl 'localhost:9200/_cluster/health?pretty'
{
"cluster_name" : "elasticsearch",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 2,
"number_of_data_nodes" : 1,
"active_primary_shards" : 456,
"active_shards" : 456,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 456
}

I am pretty new to elasticsearch but on reading up on net, i feel it's due to unassigned shards.
How can i change my status to green?

Thanks !


(Magnus Bäck) #2

You only have a single data node, yet your indexes are configured to have replicas. That creates an impossible situation since ES refuses to allocate the primary shard and replica shards on the same node. Either add a node so that you can have replicas or disable replicas. When the number of unassigned shards drops to zero the cluster will go green.


(Aditya Patel) #3

Hi Magnus,

Thanks for the reply !

I was wondering why do i have number of nodes: 2 when i am running it on a single machine. I read up on the net that it's foolhardy to disable replicas. But currently i can run it on a single machine only. Is there a way i can maintain it well on a single machine or disabling replicas is the only way to go about it.

Also i haven't worked on configuration of Elasticsearch, suppose if i do end up running it on two machines. How can i control which one is master and which one is replica. I can use one more machine but i want to put minimal processing on it.

Thanks again. :slight_smile:

@colings86 (maybe you have a few pointers on this)


(Magnus Bäck) #4

I was wondering why do i have number of nodes: 2 when i am running it on a single machine.

Perhaps Logstash is connecting using the node protocol? That would certainly explain why you have two nodes but only one data node.

I read up on the net that it's foolhardy to disable replicas. But currently i can run it on a single machine only. Is there a way i can maintain it well on a single machine or disabling replicas is the only way to go about it.

You could run multiple ES nodes on the same physical machine, but why would you want to do that? If the machine goes down all your data is unavailable either way. It basically just adds overhead.

Also i haven't worked on configuration of Elasticsearch, suppose if i do end up running it on two machines. How can i control which one is master and which one is replica.

ES dynamically chooses which node is the master node (there are no replica nodes, only replica shards). Apart from being able to configure a node to not want to become a master you can't affect the mastership election. Same thing with primary and replica shards; there are times when you want control over that but it's unusual and for now you should stick to the program and don't worry about it.

As discussed in a recent thread here, you should never have two master-eligible nodes. With two nodes it's wise to disable mastership for one of them, or jump directly to three nodes (where all are master-eligible).


(Aditya Patel) #5

Thanks for the reply !

So when i am running the ES on two machines. I should disable master in one through elasticsearch.yml file ?


(Magnus Bäck) #6

Yes, that's safer. Of course, that also means that if that node dies your cluster becomes inoperable.


(Aditya Patel) #7

Thanks!

So suppose in this scenario my master dies , my cluster would become inoperable. But would my data be safe in my non -master node?


(Magnus Bäck) #8

Yes, the non-master node and its data will be activated again as soon as the sole master comes up again.


(Aditya Patel) #9

Thanks a lot !!!!.
I also have another question. I followed the following tutorial initially to setup elasticsearch.

Everything was working fine but on some other task, i had to restart my superviosr by using the following command supervisorctl restart all

Since than i am having trouble in running the elasticsearch server continously and have to restart it again and again to work.

Can you explain how to fix this? Should i add elasticsearch conf file and run it using supervisor but than how was it working before hand?

Thanks again.


(system) #10