How to create master node cluster on the elasticsearch version 8.1.

Munawar Syukur
2 min readMar 18, 2022


In the previous article we had learned how to setup Elasticsearch and Kibana, configure kibana so it able to connect with Elasticsearch.

In this article we are going to make this node into a master node and set it as a cluster. Theoretically the minimum elasticsearch cluster required 3 nodes as it will split the background process, We will try to add the node and proceed it sequencesially to ensure the cluster and the additional nodes working within the cluster.

Let’s do the hand-ons.

To perform the activity, we must go to the 1st node that already setup and make a few amendments in the elasticsearch.yml. Where is the file located, it’s located on the /etc/elasticsearch/elasticsearch.yml. If you’re having a problem accessing the files, you need to run it as suda or run as root.

Before proceeding, to avoid mistakes along the way we can make a copy of elasticsearch.yml as a backup.

Once the backup ready, then open the file $sudo vi elasticsearch.yml then follow the steps below.

Look and amend the elasticsearch.yml on the following section.

1. my-application; remove # and change to any naming cluster;
2. node-1; remove # and change to server hostname
3.; remove # and change to non-loopback IP address
4. http.port: 9200; remove #

The step 5 and step 6 are a sample to make it more readable, please follow your hostname or ip address.
5. discovery.seed_hosts: [“”, “”, “”]
6. cluster.initial_master_nodes: [“elkmaster01”,”elkmaster02", “elkmaster03”]

7. cluster.initial_master_nodes: [“elkmaster03”] add # and change to #cluster.initial_master_nodes: [“elkmaster03”]

run these command to make the changes take effect immediately.

sudo systemctl stop elasticsearch.service
sudo systemctl start elasticsearch.service

Once the elasticsearch services up and running, run the command below to generate the token that will be used later during the additional nodes configuration.

/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node

Below is a sample token, you can ignore it because you will have new ones later.


Copy and paste your token on the command screen into other text editor, Once you have the token, then your task is complete to create the node master cluster.

In the next article, I will guide you on how to add additional nodes into the elasticsearch cluster.

Feel free to subscribe me so that you won’t miss the update, thanks.



Munawar Syukur

A Father of 4 Wonderful kids, A Loving Husband, A Casual Reader and An IT Engineer.