Configuration for cluster.initial_master_nodes

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.

# ======================== 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

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.

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

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

@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" 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

What do you get if you call _cat/nodes ?

@Christian_Dahlqvist,

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.

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

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.

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

1 Like

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 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 you should remove this parameter from your configuration once the cluster has started up for the first time. Quoting these docs:

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

2 Likes

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