# Elasticsearch failover not working with 2 nodes

**URL:** <https://discuss.elastic.co/t/elasticsearch-failover-not-working-with-2-nodes/33743>\
**Category:** Elasticsearch\
**Created:** [November 4, 2015, 12:52pm UTC](https://discuss.elastic.co/t/elasticsearch-failover-not-working-with-2-nodes/33743 "2015-11-04T12:52:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Astro-es](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@Astro-es](https://discuss.elastic.co/u/Astro-es)\
**Post date:** [November 4, 2015, 12:52pm UTC](https://discuss.elastic.co/t/elasticsearch-failover-not-working-with-2-nodes/33743/1 "2015-11-04T12:52:17Z")

</div>

I am setting up an Elasticsearch cluster with ES version 2.0.0. I have set up cluster with two nodes in EC2.

I have found following issues:

Auto discovery not working: With setup of two nodes having cluster.name same on both nodes. These nodes failed to discover each other. After changing config to described in this post I got the basic cluster working with master and slave.

Automatic failover: The cluster failed to elect slave as master when node 1 was stopped which made the cluster inoperable.

What may be the reason that the ES cluster not doing failover?

I see nothing extra in logs except

[discovery.zen] [stag-elastic-node-2] master left (reason = shut\_down),.....  
No logs related to election appears in log file of any node.

Config file node 1:

cluster.name: stag-elastic-cluster  
node.name: stag-elastic-node-1  
index.number\_of\_shards: 2  
index.number\_of\_replicas: 1  
network.host: 0.0.0.0  
discovery.zen.ping.multicast.enabled: false  
discovery.zen.ping.unicast.hosts: ["10.x.x.x","10.x.x.x"]  
Config file node 2:

cluster.name: stag-elastic-cluster  
node.name: stag-elastic-node-2  
index.number\_of\_shards: 2  
index.number\_of\_replicas: 1  
network.host: 0.0.0.0  
discovery.zen.ping.multicast.enabled: false  
discovery.zen.ping.unicast.hosts: ["10.x.x.x","10.x.x.x"]  
Ports 9200 and 9300 are open in both directions. Any help will be appreciated.

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [November 4, 2015, 3:36pm UTC](https://discuss.elastic.co/t/elasticsearch-failover-not-working-with-2-nodes/33743/2 "2015-11-04T15:36:05Z")

</div>

I suspect some of the issues your are seeing might be due to trying to set up unicast discovery on EC2. You should look into using the cloud-aws plugin instead to do discovery in EC2. [https://www.elastic.co/guide/en/elasticsearch/plugins/2.0/cloud-aws.html](https://www.elastic.co/guide/en/elasticsearch/plugins/2.0/cloud-aws.html)

---

<div class="post-metadata">

**Author:** ![Astro-es](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@Astro-es](https://discuss.elastic.co/u/Astro-es)\
**Post date:** [November 5, 2015, 5:31am UTC](https://discuss.elastic.co/t/elasticsearch-failover-not-working-with-2-nodes/33743/3 "2015-11-05T05:31:21Z")

</div>

Thanks, jpountz!

I tried to revert back to the default config in elasticsearch.yml like this:

Config file node 1:  
cluster.name: stag-elastic-cluster  
node.name: stag-elastic-node-1  
index.number\_of\_shards: 2  
index.number\_of\_replicas: 1  
network.host: 0.0.0.0

Config file node 2:  
cluster.name: stag-elastic-cluster  
node.name: stag-elastic-node-2  
index.number\_of\_shards: 2  
index.number\_of\_replicas: 1  
network.host: 0.0.0.0

and installed aws-cloud plugin. After restarting both of these nodes they should have auto discovered themselves to form a cluster, since the cluster name is same in both of this nodes. This seems to be not working in this case.

---

<div class="post-metadata">

**Author:** ![niraj\_kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_kumar/32/4130_2.png) [@niraj\_kumar](https://discuss.elastic.co/u/niraj_kumar)\
**Post date:** [November 5, 2015, 6:24am UTC](https://discuss.elastic.co/t/elasticsearch-failover-not-working-with-2-nodes/33743/4 "2015-11-05T06:24:22Z")

</div>

@Astro-es There is no cloud aws plugin settings in your elasticsearch.yml file?

cloud.aws.access\_key: ACCESS\_KEY\_HERE

cloud.aws.secret\_key: SECRET\_KEY\_HERE

cloud.aws.region: us-east-1

discovery.type: ec2

---

<div class="post-metadata">

**Author:** ![Astro-es](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@Astro-es](https://discuss.elastic.co/u/Astro-es)\
**Post date:** [November 5, 2015, 6:55am UTC](https://discuss.elastic.co/t/elasticsearch-failover-not-working-with-2-nodes/33743/5 "2015-11-05T06:55:01Z")

</div>

Hi Niraj,

These settings seems to be removed from elasticsearch.yml in version 2.0.0.  
Also, these settings may be required for Snapshot and Restore. If I am not wrong.

Thanks,

---

<div class="post-metadata">

**Author:** ![niraj\_kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_kumar/32/4130_2.png) [@niraj\_kumar](https://discuss.elastic.co/u/niraj_kumar)\
**Post date:** [November 5, 2015, 7:40am UTC](https://discuss.elastic.co/t/elasticsearch-failover-not-working-with-2-nodes/33743/6 "2015-11-05T07:40:38Z")

</div>

@Astro-es

Seeing this link  
[https://www.elastic.co/guide/en/elasticsearch/plugins/master/discovery-ec2-discovery.html](https://www.elastic.co/guide/en/elasticsearch/plugins/master/discovery-ec2-discovery.html)

> **[elastic/elasticsearch-cloud-aws](https://github.com/elastic/elasticsearch-cloud-aws)**
>
> elasticsearch-cloud-aws - AWS Cloud Plugin for Elasticsearch

I see that you have to set a tag to access it. But i am confused as to where the cloud-aws plugin will accept credentials from. Simply installing the plugin doesnt make sense as it doesn't know which credentials to use. Sorry i haven't used this in 2.0 but the above settings works for me the downgraded version.

--  
Niraj

---

<div class="post-metadata">

**Author:** ![Astro-es](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@Astro-es](https://discuss.elastic.co/u/Astro-es)\
**Post date:** [November 5, 2015, 7:50am UTC](https://discuss.elastic.co/t/elasticsearch-failover-not-working-with-2-nodes/33743/7 "2015-11-05T07:50:05Z")

</div>

@niraj_kumar

I have noticed that the nodes have discovered each other after installing this plugin.  
Note: No changes were made to config file elasticsearch.yml. regarding ec2 discovery.

Seems that it took some time for nodes to discover each other and form a cluster after the plugin was installed. Also, the failover is working as expected.

Thanks!

---

<div class="post-metadata">

**Author:** ![niraj\_kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_kumar/32/4130_2.png) [@niraj\_kumar](https://discuss.elastic.co/u/niraj_kumar)\
**Post date:** [November 5, 2015, 7:56am UTC](https://discuss.elastic.co/t/elasticsearch-failover-not-working-with-2-nodes/33743/8 "2015-11-05T07:56:46Z")

</div>

Is your EC2 system have the credentials been stored anywhere. I mean how can the plugin know where the credential is. It simply cannot go and join anyway.

I am glad it worked for you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:40pm UTC](https://discuss.elastic.co/t/elasticsearch-failover-not-working-with-2-nodes/33743/9 "2017-07-05T23:40:25Z")

</div>


