# How to form a cluster?

**URL:** <https://discuss.elastic.co/t/how-to-form-a-cluster/113892>\
**Category:** Elasticsearch\
**Created:** [January 3, 2018, 8:54am UTC](https://discuss.elastic.co/t/how-to-form-a-cluster/113892 "2018-01-03T08:54:59Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Terry](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@Terry](https://discuss.elastic.co/u/Terry)\
**Post date:** [January 3, 2018, 8:54am UTC](https://discuss.elastic.co/t/how-to-form-a-cluster/113892/1 "2018-01-03T08:54:59Z")

</div>

I have two nodes as below which belong to the same cluster elasticsearch. However, the number of nodes showing only 1 instead of 2. How to form a cluster?

{  
"name" : "OANlHwb",  
"cluster\_name" : "elasticsearch",  
"cluster\_uuid" : "hHfTcg\_BTfOH9PBkuOXXww",  
"version" : {  
"number" : "6.0.0",  
"build\_hash" : "8f0685b",  
"build\_date" : "2017-11-10T18:41:22.859Z",  
"build\_snapshot" : false,  
"lucene\_version" : "7.0.1",  
"minimum\_wire\_compatibility\_version" : "5.6.0",  
"minimum\_index\_compatibility\_version" : "5.0.0"  
},  
"tagline" : "You Know, for Search"  
}  
{  
"cluster\_name" : "elasticsearch",  
"status" : "red",  
"timed\_out" : false,  
"number\_of\_nodes" : 1,  
"number\_of\_data\_nodes" : 1,  
"active\_primary\_shards" : 2291,  
"active\_shards" : 2291,  
"relocating\_shards" : 0,  
"initializing\_shards" : 4,  
"unassigned\_shards" : 2423,  
"delayed\_unassigned\_shards" : 0,  
"number\_of\_pending\_tasks" : 11,  
"number\_of\_in\_flight\_fetch" : 0,  
"task\_max\_waiting\_in\_queue\_millis" : 450065,  
"active\_shards\_percent\_as\_number" : 48.558711318355236  
}

{  
"name" : "DMSUATOWAS",  
"cluster\_name" : "elasticsearch",  
"cluster\_uuid" : "Wo11S5vZT\_akDT5CHKkeIA",  
"version" : {  
"number" : "6.0.0",  
"build\_hash" : "8f0685b",  
"build\_date" : "2017-11-10T18:41:22.859Z",  
"build\_snapshot" : false,  
"lucene\_version" : "7.0.1",  
"minimum\_wire\_compatibility\_version" : "5.6.0",  
"minimum\_index\_compatibility\_version" : "5.0.0"  
},  
"tagline" : "You Know, for Search"  
}  
{  
"cluster\_name" : "elasticsearch",  
"status" : "yellow",  
"timed\_out" : false,  
"number\_of\_nodes" : 1,  
"number\_of\_data\_nodes" : 1,  
"active\_primary\_shards" : 5018,  
"active\_shards" : 5018,  
"relocating\_shards" : 0,  
"initializing\_shards" : 0,  
"unassigned\_shards" : 5018,  
"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" : 50.0  
}

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 3, 2018, 8:56am UTC](https://discuss.elastic.co/t/how-to-form-a-cluster/113892/2 "2018-01-03T08:56:08Z")

</div>

Please show your settings, and remember to use the `</>` (code) button to make sure things are correctly formatted.

---

<div class="post-metadata">

**Author:** ![Terry](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@Terry](https://discuss.elastic.co/u/Terry)\
**Post date:** [January 3, 2018, 9:52am UTC](https://discuss.elastic.co/t/how-to-form-a-cluster/113892/3 "2018-01-03T09:52:24Z")

</div>

Do you mean the elasticsearch.yml file?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 3, 2018, 9:53am UTC](https://discuss.elastic.co/t/how-to-form-a-cluster/113892/4 "2018-01-03T09:53:59Z")

</div>

Yep.

---

<div class="post-metadata">

**Author:** ![Terry](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@Terry](https://discuss.elastic.co/u/Terry)\
**Post date:** [January 4, 2018, 7:56am UTC](https://discuss.elastic.co/t/how-to-form-a-cluster/113892/5 "2018-01-04T07:56:23Z")

</div>

I have only changed network.host to the actual IP of the node in the elasticsearch.yml file. So, the default cluster name of elasticsearch. Does this work? Or I need to change the [cluster.name](http://cluster.name) and [node.name](http://node.name) as well?

---

<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:** [January 4, 2018, 8:24am UTC](https://discuss.elastic.co/t/how-to-form-a-cluster/113892/6 "2018-01-04T08:24:43Z")

</div>

That is a LOT of shards for a 1/2 node cluster. I would recommend reducing this significantly before clustering the nodes and getting replicas enabled. Have a look at [this blog post for guidance around shards and sharding](https://www.elastic.co/blog/how-many-shards-should-i-have-in-my-elasticsearch-cluster).

---

<div class="post-metadata">

**Author:** ![Terry](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@Terry](https://discuss.elastic.co/u/Terry)\
**Post date:** [January 4, 2018, 9:54am UTC](https://discuss.elastic.co/t/how-to-form-a-cluster/113892/7 "2018-01-04T09:54:34Z")

</div>

I haven't configured the shards. Isn't it default to 5? Why it got a lot of shards?

---

<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:** [January 4, 2018, 9:58am UTC](https://discuss.elastic.co/t/how-to-form-a-cluster/113892/8 "2018-01-04T09:58:10Z")

</div>

Default is 5 shards, which may very well be too much for your use case. The link I provided provides some reasonably generic guidance of target shards size and count per node.

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [January 5, 2018, 1:33am UTC](https://discuss.elastic.co/t/how-to-form-a-cluster/113892/9 "2018-01-05T01:33:17Z")

</div>

> [@Terry](#):
>
> I have only changed network.host to the actual IP of the node in the elasticsearch.yml

The most likely cause is that your nodes cannot communicate with one another.  
If you didn't configure anything else in your elasticsearch.yml configuration, then the nodes don't know that they're supposed to be part of a multi-node cluster, so if they can't find another node to join up with, they will happily form a single-node cluster on their own.

Without knowing how your network is setup, I can't offer concrete advice on this, but the most likely cause is:

- You have changed `network.host` to be the public IP address for your machines. That means it binds to that IP only, and does not bind the localhost/127.0.0.1 interface any more
- You have not changed `discovery.zen.ping.unicast.hosts` so it's using the default value which only looks for other nodes on the same machine using the local interface (127.0.0.1 and the equivalent for IPv6)

The fix for you is probably going to be to set `discovery.zen.ping.unicast.hosts`.  
In order to prevent your nodes from creating two separate clusters (when they are unable to communicate) you should also look at either setting `discovery.zen.minimum_master_nodes: 2` on both nodes, or set `node.master: false` on _one_ of the nodes.

**Note** : A 2 node cluster isn't really a good idea, but I assume this is simply a test/lab setup rather than a production scenario.

---

<div class="post-metadata">

**Author:** ![Terry](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@Terry](https://discuss.elastic.co/u/Terry)\
**Post date:** [January 8, 2018, 9:40am UTC](https://discuss.elastic.co/t/how-to-form-a-cluster/113892/10 "2018-01-08T09:40:30Z")

</div>

I got one node that I have changed the network.host to actual IP in elasticsearch.yml. But it seems that any changes in elasticsearch.yml won't applied even after I have restarted the elasticsearch service or reboot the whole server. The elasticsearch can be accessed by [http://127.0.0.1:9200/](http://127.0.0.1:9200/) but not the actual IP even though I have configured the network.host to actual IP. I used a Windows version of elasticsearch. Is there anything wrong with it? Or it will be better if I install it again?

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [January 8, 2018, 9:55am UTC](https://discuss.elastic.co/t/how-to-form-a-cluster/113892/11 "2018-01-08T09:55:22Z")

</div>

What you are experiencing doesn't sound right. In these situations it usually turns out to be a configuration problem such as:

- editing the wrong configuration file
- not removing the leading `#` character from the relevant line in the configuration file
- not actually restarting Elasticsearch (or restarting the wrong instance)

I'm happy to help track it down with you, but there's not enough detail on your message to be able to narrow down the problem.

Steps you could take are:

- add some garbage characters to the bottom of your configuration file, and restart ES. The node should fail. This will help confirm whether you are editing the correct file.
- post your config file here for us to check.
- check the ES logs for more details. The logs tell you what address it's trying to bind to.

---

<div class="post-metadata">

**Author:** ![Terry](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@Terry](https://discuss.elastic.co/u/Terry)\
**Post date:** [January 10, 2018, 6:45am UTC](https://discuss.elastic.co/t/how-to-form-a-cluster/113892/12 "2018-01-10T06:45:45Z")

</div>

The elasticsearch.yml is in the path C:\ELK-Stack\elasticsearch\config. I have removed the IPs here.  
I found that it is missing the data folder under elasticsearch directory and hence no index. How to fix it?

# ======================== 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](https://www.elastic.co/guide/en/elasticsearch/reference/index.html)

# 

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

# 

# Use a descriptive name for your cluster:

# 

#[cluster.name](http://cluster.name): my-application

# 

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

# 

# Use a descriptive name for the node:

# 

#[node.name](http://node.name): node-1

# 

# 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: /path/to/data

# 

# Path to log files:

# 

#path.logs: /path/to/logs

# 

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

# 

# 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 new node is started:

# The default list of hosts is ["127.0.0.1", "[::1]"]

# 

discovery.zen.ping.unicast.hosts: ["", ""]

# 

# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):

# 

discovery.zen.minimum\_master\_nodes: 2

# 

# For more information, consult the zen discovery 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:** ![Terry](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@Terry](https://discuss.elastic.co/u/Terry)\
**Post date:** [January 10, 2018, 8:53am UTC](https://discuss.elastic.co/t/how-to-form-a-cluster/113892/13 "2018-01-10T08:53:57Z")

</div>

There is also no logs folder created. I noticed that there are no data and logs folder under the elasticsearch directory when extracting from the source file. What wrong with it?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 10, 2018, 8:56am UTC](https://discuss.elastic.co/t/how-to-form-a-cluster/113892/14 "2018-01-10T08:56:26Z")

</div>

Can you please edit that config and use the `</>` button to format it as code, it's really hard to read as is.

---

<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:** [February 7, 2018, 8:57am UTC](https://discuss.elastic.co/t/how-to-form-a-cluster/113892/15 "2018-02-07T08:57:14Z")

</div>

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