# Configuration for cluster.initial\_master\_nodes

**URL:** <https://discuss.elastic.co/t/configuration-for-cluster-initial-master-nodes/229754>\
**Category:** Elasticsearch\
**Created:** [April 25, 2020, 11:13am UTC](https://discuss.elastic.co/t/configuration-for-cluster-initial-master-nodes/229754 "2020-04-25T11:13:26Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dev\_Chakraborty](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dev_chakraborty/32/45546_2.png) [@Dev\_Chakraborty](https://discuss.elastic.co/u/Dev_Chakraborty)\
**Post date:** [April 25, 2020, 11:13am UTC](https://discuss.elastic.co/t/configuration-for-cluster-initial-master-nodes/229754/1 "2020-04-25T11:13:26Z")

</div>

Hello Folks,

I have three nodes, 2 dedicated for Elasticsearch and one is ES+Kibana. Below is my elasticsearch.yml file,can you suggest on cluster.initial\_master\_nodes, how it should be mentioned if I want only two nodes of that cluster to be master, is my below config is correct? ES version is 7.6.2.

```auto
# ======================== Elasticsearch Configuration =========================

#

# NOTE: Elasticsearch comes with reasonable defaults for most settings.

# Before you set out to tweak and tune the configuration, make sure you

# understand what are you trying to accomplish and the consequences.

#

# The primary way of configuring a node is via this file. This template lists

# the most important settings you may want to configure for a production cluster.

#

# Please consult the documentation for further information on configuration options:

# https://www.elastic.co/guide/en/elasticsearch/reference/index.html

#

# ---------------------------------- Cluster -----------------------------------

#

# Use a descriptive name for your cluster:

#

cluster.name: clustername

#

# ------------------------------------ Node ------------------------------------

#

# Use a descriptive name for the node:

#
node.name: ip-MachineIP.region.compute.internal
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/lib/elasticsearch
#
#Path to log files:
path.logs: /var/log/elasticsearch
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this limit.
#
#Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: XXX.XX.X.XX
#
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["XXX.XX.X.XX", "XXX.XX.X.XXX", " XXX.XX.X.XXX "]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["ip-MachineIP. region.compute.internal ", " ip-MachineIP. region compute.internal"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

```

---

<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 25, 2020, 11:16am UTC](https://discuss.elastic.co/t/configuration-for-cluster-initial-master-nodes/229754/2 "2020-04-25T11:16:41Z")

</div>

> [@Dev\_Chakraborty](#):
>
> I want only two nodes of that cluster to be master

That is a bad idea. You should ALWAYS look to have at least 3 master eligible nodes in a cluster as that will allow you to lose one node. With only 2 master eligible nodes both need to be available for a fully functioning cluster.

Also please format your config as it is hard to read.

---

<div class="post-metadata">

**Author:** ![Dev\_Chakraborty](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dev_chakraborty/32/45546_2.png) [@Dev\_Chakraborty](https://discuss.elastic.co/u/Dev_Chakraborty)\
**Post date:** [April 25, 2020, 11:27am UTC](https://discuss.elastic.co/t/configuration-for-cluster-initial-master-nodes/229754/3 "2020-04-25T11:27:54Z")

</div>

Hello, @Christian_Dahlqvist, Can you read the file now?

---

<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 25, 2020, 11:29am UTC](https://discuss.elastic.co/t/configuration-for-cluster-initial-master-nodes/229754/4 "2020-04-25T11:29:58Z")

</div>

It looks mostly fine although you seem to have spaces within the host name, node name and IP strings.

---

<div class="post-metadata">

**Author:** ![Dev\_Chakraborty](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dev_chakraborty/32/45546_2.png) [@Dev\_Chakraborty](https://discuss.elastic.co/u/Dev_Chakraborty)\
**Post date:** [April 25, 2020, 11:38am UTC](https://discuss.elastic.co/t/configuration-for-cluster-initial-master-nodes/229754/5 "2020-04-25T11:38:20Z")

</div>

@Christian_Dahlqvist, YML file is fine , have validated already, could be issue while pasting here, for this parameter 'cluster.initial\_master\_nodes', all the nodes in cluster should be there something like below:

cluster.initial\_master\_nodes: ["node-1 ", " node-2", "node-3"], when i try to do this and run command "curl -X GET "[http://XXX.XX.XX.XX:9200/\_cat/master?v&pretty](http://XXX.XX.XX.XX:9200/_cat/master?v&pretty)" to get master node, it always shows the first node something as below:  
'''  
curl -X GET "http:// XXX.XX.X.XX :9200/\_cat/master?v&pretty"  
id host ip node  
id-name XXX.XX.XX.XX XXX.XX.X.XX ip- XXX.XX.X.XX .region.compute.internal

```auto

```

---

<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 25, 2020, 11:39am UTC](https://discuss.elastic.co/t/configuration-for-cluster-initial-master-nodes/229754/6 "2020-04-25T11:39:41Z")

</div>

What do you get if you call `_cat/nodes` ?

---

<div class="post-metadata">

**Author:** ![Dev\_Chakraborty](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dev_chakraborty/32/45546_2.png) [@Dev\_Chakraborty](https://discuss.elastic.co/u/Dev_Chakraborty)\
**Post date:** [April 25, 2020, 11:46am UTC](https://discuss.elastic.co/t/configuration-for-cluster-initial-master-nodes/229754/7 "2020-04-25T11:46:57Z")

</div>

@Christian_Dahlqvist,

```auto
XXX.XX.XX.XXX 14 8 0 0.00 0.00 0.00 dilm - ip-XXX.XX.XX.XXX.region.compute.internal
XXX.XX.XX.XXX 31 13 0 0.00 0.00 0.00 dilm - ip-XXX.XX.XX.XXX.region.compute.internal
XXX.XX.XX.XXX 27 8 0 0.02 0.01 0.00 dilm * ip-XXX.XX.XX.XXX.region.compute.internal 

```

As you can see last node shows as master.

---

<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 25, 2020, 11:48am UTC](https://discuss.elastic.co/t/configuration-for-cluster-initial-master-nodes/229754/8 "2020-04-25T11:48:00Z")

</div>

Yes. Any of the nodes can be elected master at any point so that looks good.

---

<div class="post-metadata">

**Author:** ![Dev\_Chakraborty](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dev_chakraborty/32/45546_2.png) [@Dev\_Chakraborty](https://discuss.elastic.co/u/Dev_Chakraborty)\
**Post date:** [April 25, 2020, 12:00pm UTC](https://discuss.elastic.co/t/configuration-for-cluster-initial-master-nodes/229754/9 "2020-04-25T12:00:32Z")

</div>

Thank you @Christian_Dahlqvist .I have tested that after shutdown two master nodes which i have defined here cluster.initial\_master\_nodes and then tried to run from third server curl -X GET "localhost:9200/\_cat/nodes?v&pretty, it did not give any o/p, which was expected.

---

<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 25, 2020, 12:45pm UTC](https://discuss.elastic.co/t/configuration-for-cluster-initial-master-nodes/229754/10 "2020-04-25T12:45:07Z")

</div>

Yes, you always need a majority of master eligible nodes available for a fully functioning cluster.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [April 25, 2020, 3:22pm UTC](https://discuss.elastic.co/t/configuration-for-cluster-initial-master-nodes/229754/11 "2020-04-25T15:22:32Z")

</div>

> [@Christian\_Dahlqvist](#):
>
> That is a bad idea. You should ALWAYS look to have at least 3 master eligible nodes in a cluster as that will allow you to lose one node. With only 2 master eligible nodes both need to be available for a fully functioning cluster.

This is technically true @Christian_Dahlqvist, but you can set one of the 3 master-eligible nodes to be a [voting-only master-eligible node](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-node.html#voting-only-node) which means it'll participate in elections but will never itself be elected as the master, ensuring that the elected master is always one of the other two nodes.

> [@Dev\_Chakraborty](#):
>
> for this parameter 'cluster.initial\_master\_nodes',

@Dev_Chakraborty you should remove this parameter from your configuration once the cluster has started up for the first time. Quoting [these docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/discovery-settings.html#initial_master_nodes):

> You should not use this setting when restarting a cluster or adding a new node to an existing cluster.

---

<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 23, 2020, 5:06pm UTC](https://discuss.elastic.co/t/configuration-for-cluster-initial-master-nodes/229754/13 "2020-05-23T17:06:03Z")

</div>

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