# Ha in two node elasticsearch

**URL:** https://discuss.elastic.co/t/ha-in-two-node-elasticsearch/330819
**Category:** Elasticsearch
**Created:** [April 26, 2023, 10:14am UTC](https://discuss.elastic.co/t/ha-in-two-node-elasticsearch/330819 "2023-04-26T10:14:24Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Monish22](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@Monish22](https://discuss.elastic.co/u/Monish22)
#### Post date: [April 26, 2023, 10:14am UTC](https://discuss.elastic.co/t/ha-in-two-node-elasticsearch/330819/1 "2023-04-26T10:14:24Z")

</div>

Hi,

Currently, we setup two node elasticsearch cluster in my lab and configured ha. We set the both the nodes are master and data. but when the elk01 master node is down, the elk02 doesnt take the leader process.

ELK02 node LOG :

[2023-04-26T05:53:24,772][WARN][o.e.c.c.ClusterFormationFailureHelper] [elk02] master not discovered or elected yet, an election requires a node with id [bwJj1LCyTN2Abv\_OdGuI1g], have only discovered non-quorum [{elk02}{Auut4OPBRWCJVZF8HTVDnA}{-g\_C18DMTW-krUVX8HCD1Q}{elk02}{192.168.170.36}{192.168.170.36:9300}{dm}{8.7.0}]; discovery will continue using [192.168.170.7:9300] from hosts providers and [{elk02}{Auut4OPBRWCJVZF8HTVDnA}{-g\_C18DMTW-krUVX8HCD1Q}{elk02}{192.168.170.36}{192.168.170.36:9300}{dm}{8.7.0}] from last-known cluster state; node term 6, last-accepted version 93 in term 6; for troubleshooting guidance, see [Troubleshooting discovery | Elasticsearch Guide [8.7] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/8.7/discovery-troubleshooting.html)  
[2023-04-26T05:53:24,852][WARN][o.e.d.PeerFinder] [elk02] address [192.168.170.7:9300], node [null], requesting [false] discovery result: [192.168.170.7:9300] connect\_exception: Failed execution: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: elk01/192.168.170.7:9300: Connection refused: elk01/192.168.170.7:9300: Connection refused  
[2023-04-26T05:53:25,854][WARN][o.e.d.PeerFinder] [elk02] address [192.168.170.7:9300], node [null], requesting [false] discovery result: [192.168.170.7:9300] connect\_exception: Failed execution: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: elk01/192.168.170.7:9300: Connection refused: elk01/192.168.170.7:9300: Connection refused  
[2023-04-26T05:53:26,853][WARN][o.e.d.PeerFinder] [elk02] address [192.168.170.7:9300], node [null], requesting [false] discovery result: [192.168.170.7:9300] connect\_exception: Failed execution: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: elk01/192.168.170.7:9300: Connection refused: elk01/192.168.170.7:9300: Connection refused  
[2023-04-26T05:53:27,854][WARN][o.e.d.PeerFinder] [elk02] address [192.168.170.7:9300], node [null], requesting [false] discovery result: [192.168.170.7:9300] connect\_exception: Failed execution: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: elk01/192.168.170.7:9300: Connection refused: elk01/192.168.170.7:9300: Connection refused

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [April 26, 2023, 10:37am UTC](https://discuss.elastic.co/t/ha-in-two-node-elasticsearch/330819/2 "2023-04-26T10:37:03Z")

</div>

This is expected. You need at least 3 nodes to achieve HA as Elasticsearch requires a strict majority of nodes to be available in order to elect a master and be fully functioning. See [this section in the docs](https://www.elastic.co/guide/en/elasticsearch/reference/8.7/high-availability-cluster-small-clusters.html) for more information.

---

<div class="post-metadata">

### Author: ![Monish22](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@Monish22](https://discuss.elastic.co/u/Monish22)
#### Post date: [April 26, 2023, 10:40am UTC](https://discuss.elastic.co/t/ha-in-two-node-elasticsearch/330819/3 "2023-04-26T10:40:36Z")

</div>

Hi Christian,

If its possible can we manually change the elasticsearch master , when the node is gone ?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [April 26, 2023, 10:42am UTC](https://discuss.elastic.co/t/ha-in-two-node-elasticsearch/330819/4 "2023-04-26T10:42:00Z")

</div>

No, there is no safe way to do that. There is a tool that can help you reconfigure the cluster but it is not safe and can result in data loss. If you want HA you should not rely on this and instead add a third node. Note that the third node can be a smaller dedicated master node.

---

<div class="post-metadata">

### Author: ![Monish22](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@Monish22](https://discuss.elastic.co/u/Monish22)
#### Post date: [April 26, 2023, 10:47am UTC](https://discuss.elastic.co/t/ha-in-two-node-elasticsearch/330819/5 "2023-04-26T10:47:17Z")

</div>

Hi Christian,

Then i plan for four nodes elasticsearch. two nodes will be a master and data.

Another two node will be only master. Now, if the two nodes, 1 master only node and 1 data and master node is down can i use the elasticsearch right ?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [April 26, 2023, 10:48am UTC](https://discuss.elastic.co/t/ha-in-two-node-elasticsearch/330819/6 "2023-04-26T10:48:52Z")

</div>

If you have 4 master eligible nodes you need 3 (majority) to be available in order to elect a master. I would therfore go for 3 nodes on 3 different hosts.

---

<div class="post-metadata">

### Author: ![Monish22](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@Monish22](https://discuss.elastic.co/u/Monish22)
#### Post date: [April 26, 2023, 10:49am UTC](https://discuss.elastic.co/t/ha-in-two-node-elasticsearch/330819/7 "2023-04-26T10:49:59Z")

</div>

Hi Christian ,

But here we have only 2 hosts. Let me know how to configure ?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [April 26, 2023, 10:50am UTC](https://discuss.elastic.co/t/ha-in-two-node-elasticsearch/330819/8 "2023-04-26T10:50:47Z")

</div>

You can not have a fully HA cluster with just 2 hosts. You need a small third host. There is no way around this.

---

<div class="post-metadata">

### Author: ![Monish22](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@Monish22](https://discuss.elastic.co/u/Monish22)
#### Post date: [April 26, 2023, 12:48pm UTC](https://discuss.elastic.co/t/ha-in-two-node-elasticsearch/330819/9 "2023-04-26T12:48:09Z")

</div>

Hi Christian,

If we create 5 nodes elasticsearch, if we down 3 nodes also its working fine right ?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [April 26, 2023, 12:58pm UTC](https://discuss.elastic.co/t/ha-in-two-node-elasticsearch/330819/10 "2023-04-26T12:58:07Z")

</div>

No. If you have 5 master eligible nodes you need 3 to be available in order to form a majority. In this case you can only afford to lose 2 nodes.

---

<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: [May 24, 2023, 12:58pm UTC](https://discuss.elastic.co/t/ha-in-two-node-elasticsearch/330819/11 "2023-05-24T12:58:07Z")

</div>

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