# How make a master node in a 3 node cluster?

**URL:** <https://discuss.elastic.co/t/how-make-a-master-node-in-a-3-node-cluster/324656>\
**Category:** Elasticsearch\
**Created:** [February 3, 2023, 2:06pm UTC](https://discuss.elastic.co/t/how-make-a-master-node-in-a-3-node-cluster/324656 "2023-02-03T14:06:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![H\_K7](https://avatars.discourse-cdn.com/v4/letter/h/4da419/32.png) [@H\_K7](https://discuss.elastic.co/u/H_K7)\
**Post date:** [February 3, 2023, 2:06pm UTC](https://discuss.elastic.co/t/how-make-a-master-node-in-a-3-node-cluster/324656/1 "2023-02-03T14:06:52Z")

</div>

Current 3 node cluster setup

I have setup 3 node cluster

```auto
{
  "cluster_name" : "DEMOCLUSTER",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 3,
  "number_of_data_nodes" : 3,
  "active_primary_shards" : 2,
  "active_shards" : 4,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}

```

if i set node.roles to master for one node and restart I get the below errors

```auto
node.roles:
- master

```

```auto
[ERROR][o.e.b.Elasticsearch] [ip-.ec2.internal] fatal exception while booting Elasticsearch
java.lang.IllegalStateException: node does not have the data role but has shard data: [/var/lib/elasticsearch/indices/0rSKvI5aSH2g4UzMkZanNA/0, /var/lib/elasticsearch/indices/palG910hQ9aZnoXiFL5jQg/0]. Use 'elasticsearch-node repurpose' tool to clean up

```

If i did elasticsearch-node repurpose, cluster goes bad and also not able access curl cluster health with elastic password.

Now what's the order/how to set one node as master here and have a working 1 master 2 data cluster ?

How Can i further grow the cluster into something like 3 master, 6 data ?

---

<div class="post-metadata">

**Author:** ![Ayush\_Mathur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ayush_mathur/32/77134_2.png) [@Ayush\_Mathur](https://discuss.elastic.co/u/Ayush_Mathur)\
**Post date:** [February 3, 2023, 2:11pm UTC](https://discuss.elastic.co/t/how-make-a-master-node-in-a-3-node-cluster/324656/2 "2023-02-03T14:11:24Z")

</div>

@H_K7 welcome to the community !  
The node roles are essentially assigned during configuring them before actually spinning up the cluster. Since you already have data in all nodes, you cannot change a data node to master without moving shards.  
One approach could be to first set `exclude_ip` in your dynamic cluster settings to move shards out of that node and assign them to remaining nodes. Then you can juggle with the nodes roles and make that node as master.  
Since you have a new cluster, best would be to start from configuring them and may be use `cluster.initial_master_nodes` setting to tell cluster nodes which one is master. In addition, set the node.roles for each ES node so they don't assume master role when initial one goes down.

---

<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:** [February 3, 2023, 2:12pm UTC](https://discuss.elastic.co/t/how-make-a-master-node-in-a-3-node-cluster/324656/3 "2023-02-03T14:12:44Z")

</div>

You should always aim to have 3 master eligible nodes in your cluster. If you have only 3 nodes that would therefore mean that all are master eligible. If you then want to transition to a cluster with 3 dedicated master nodes and 6 data nodes you add the data nodes first and then make the master eligible nodes dedicated master nodes one at a time.

---

<div class="post-metadata">

**Author:** ![H\_K7](https://avatars.discourse-cdn.com/v4/letter/h/4da419/32.png) [@H\_K7](https://discuss.elastic.co/u/H_K7)\
**Post date:** [February 3, 2023, 5:00pm UTC](https://discuss.elastic.co/t/how-make-a-master-node-in-a-3-node-cluster/324656/4 "2023-02-03T17:00:50Z")

</div>

@Christian_Dahlqvist, @Ayush_Mathur , Thanks for the response,  
Also If I create the very first Node(before even creating the other 2 nodes which I planned for 3node cluster) with node.roles as master, It errors to start up, Below is the config

```auto
cluster.name: demoCLUSTER
node.name: ip-FIRSTNODE.ec2.internal
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
http.port: 9200
node.roles:
- master
discovery.seed_hosts: ["ip-FIRSTNODE.ec2.internal"]
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:
  enabled: true
  keystore.path: certs/http.p12
xpack.security.transport.ssl:
  enabled: true
  verification_mode: certificate
  keystore.path: certs/transport.p12
  truststore.path: certs/transport.p12
cluster.initial_master_nodes: ["ip-FIRSTNODE.ec2.internal"]
http.host: 0.0.0.0

```

Not sure why it doesn't work that way, But is it also that's why we should'nt create the very first node as master ?  
Thanks

---

<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:** [February 3, 2023, 6:43pm UTC](https://discuss.elastic.co/t/how-make-a-master-node-in-a-3-node-cluster/324656/5 "2023-02-03T18:43:34Z")

</div>

If you have only 3 nodes, let them have all roles and not be dedicated masters.

It would also help if you showed the exact error message from the logs.

---

<div class="post-metadata">

**Author:** ![H\_K7](https://avatars.discourse-cdn.com/v4/letter/h/4da419/32.png) [@H\_K7](https://discuss.elastic.co/u/H_K7)\
**Post date:** [February 3, 2023, 7:26pm UTC](https://discuss.elastic.co/t/how-make-a-master-node-in-a-3-node-cluster/324656/6 "2023-02-03T19:26:52Z")

</div>

@Christian_Dahlqvist  
Right now these are the only logs I have for the above mentioned single node (which I tried to assign master)

```auto
2023-02-03T11:12:34,589][INFO][o.e.l.LicenseService] [ip-FIRSTNODE.ec2.internal] license [2afd032d-5e75-4771-8836-abcce96b1160] mode [basic] - valid
[2023-02-03T11:12:34,590][INFO][o.e.x.s.a.Realms] [ip-FIRSTNODE.ec2.internal] license mode is [basic], currently licensed security realms are [reserved/reserved,file/default_file,native/default_native]
[2023-02-03T11:13:02,903][WARN][o.e.c.c.Coordinator] [ip-FIRSTNODE.ec2.internal] This node is a fully-formed single-node cluster with cluster UUID [CWeTC4bJR_e7C6sJDbQRtg], but it is configured as if to discover other nodes and form a multi-node cluster via the [discovery.seed_hosts=[ip-FIRSTNODE.ec2.internal]] setting. Fully-formed clusters do not attempt to discover other nodes, and nodes with different cluster UUIDs cannot belong to the same cluster. The cluster UUID persists across restarts and can only be changed by deleting the contents of the node's data path(s). Remove the discovery configuration to suppress this message.

```

---

<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:** [March 3, 2023, 7:27pm UTC](https://discuss.elastic.co/t/how-make-a-master-node-in-a-3-node-cluster/324656/7 "2023-03-03T19:27:32Z")

</div>

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