# How to add nodes to cluster through source code

**URL:** <https://discuss.elastic.co/t/how-to-add-nodes-to-cluster-through-source-code/173716>\
**Category:** Elasticsearch\
**Created:** [March 25, 2019, 10:00am UTC](https://discuss.elastic.co/t/how-to-add-nodes-to-cluster-through-source-code/173716 "2019-03-25T10:00:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MKU](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mku/32/48327_2.png) [@MKU](https://discuss.elastic.co/u/MKU)\
**Post date:** [March 25, 2019, 10:00am UTC](https://discuss.elastic.co/t/how-to-add-nodes-to-cluster-through-source-code/173716/1 "2019-03-25T10:00:23Z")

</div>

I want to add a node to my cluster(currently single node),but i want to add a node through source code.  
Which file i should look into.

---

<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:** [March 25, 2019, 10:38am UTC](https://discuss.elastic.co/t/how-to-add-nodes-to-cluster-through-source-code/173716/2 "2019-03-25T10:38:58Z")

</div>

I don't know what you mean by "through source code". Each node is a separate process, so to add a second node you just configure it and then run it.

---

<div class="post-metadata">

**Author:** ![MKU](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mku/32/48327_2.png) [@MKU](https://discuss.elastic.co/u/MKU)\
**Post date:** [March 25, 2019, 10:42am UTC](https://discuss.elastic.co/t/how-to-add-nodes-to-cluster-through-source-code/173716/3 "2019-03-25T10:42:52Z")

</div>

Hi @DavidTurner,  
i am not running elasticsearch installer,i am running elasticsearch instance by **gradlew run** in eclipse. How do i add node in this case because elasticsearch.yml gets dynamically generated.

---

<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:** [March 25, 2019, 11:29am UTC](https://discuss.elastic.co/t/how-to-add-nodes-to-cluster-through-source-code/173716/4 "2019-03-25T11:29:47Z")

</div>

Ah I see. I don't think it's possible to run multiple nodes from an IDE. You can use [remote debugging](https://github.com/elastic/elasticsearch/blob/master/TESTING.asciidoc#debugging-remotely-from-an-ide) to attach an IDE to a node started elsewhere. It's also possible to write test cases that simulate running multiple nodes: see `ESIntegTestCase` and its derived classes for examples of this.

---

<div class="post-metadata">

**Author:** ![MKU](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mku/32/48327_2.png) [@MKU](https://discuss.elastic.co/u/MKU)\
**Post date:** [April 22, 2019, 9:40am UTC](https://discuss.elastic.co/t/how-to-add-nodes-to-cluster-through-source-code/173716/5 "2019-04-22T09:40:31Z")

</div>

[In this post](https://discuss.elastic.co/t/set-up-elasticsearch-cluster-2-nodes-on-same-machine/120824/5) , he added nodes by ,  
`node.max_local_storage_nodes: 4` in `elasticsearch.yml` .

Is it not possible to **hardcode** the number of nodes in source code.

---

<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 22, 2019, 9:51am UTC](https://discuss.elastic.co/t/how-to-add-nodes-to-cluster-through-source-code/173716/6 "2019-04-22T09:51:21Z")

</div>

Setting `node.max_local_storage_nodes` doesn't run any extra nodes so I don't think it addresses your question.

There's no way to "hardcode" a setting value, but I don't see why you would want to do that. If you don't want to change it, simply don't change it!

---

<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 20, 2019, 9:51am UTC](https://discuss.elastic.co/t/how-to-add-nodes-to-cluster-through-source-code/173716/7 "2019-05-20T09:51:23Z")

</div>

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