Set up Elasticsearch cluster 2 nodes on same machine

Hi ,
The requirement is need to set up two nodes of cluster on same host. if I use network.host: with same IP
http.port : different port

Below is my config file for node-1. In 2nd node cluster name is same,node name is different , network ip is same and port number is different. when I start service for node-1 it's working fine. but elasticsearch service for node cannot start. Could any one please suggest what I missed.

The configuration file (elasticsearch.yml)for node-1 has below settings.
---------------------------------- Cluster -----------------------------------
cluster.name: "Test ES Cluster"
------------------------------------ Node ------------------------------------
node.name: "node-1"
---------------------------------- Network -----------------------------------
network.host: 10.1.1.101
http.port: 9201

The configuration file (elasticsearch.yml)for node-2 has below settings.
---------------------------------- Cluster -----------------------------------
cluster.name: "Test ES Cluster"
------------------------------------ Node ------------------------------------
node.name: "node-2"
---------------------------------- Network -----------------------------------
network.host: 10.1.1.101
http.port: 9202

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.
Please update your post.

Sure. Thanks David.

You need to tell the discovery how to discover the other nodes. See https://www.elastic.co/guide/en/elasticsearch/reference/current/discovery-settings.html

Note that it's not really recommended to have multiple nodes per machine unless you have more than 64 gb of physical RAM on your machine.
Is it your case?

Hi David,
You are right, there is no meaning of cluster node on same server. However for now on our dev server we need to configure it on same server with two nodes. so as mentioned in document you suggested, I want to set two nodes on same server. and trying ...
"Out of the box, without any network configuration, Elasticsearch will bind to the available loopback addresses and will scan ports 9300 to 9305 to try to connect to other nodes running on the same server. This provides an auto- clustering experience without having to do any configuration."

I also tried with
discovery.zen.ping.unicast.hosts: ["10.1.1.101:9300","10.1.1.101:9304"]. but with these settings,I can not start elasticsearch services.

So if it's for dev only, like running locally, you don't need to set anything like network.host and discovery.zen.ping.unicast.hosts as this will work OOTB.

But if you did not create multiple installation directories, you might have to add node.max_local_storage_nodes: 4 in your elasticsearch.yml.

If you don't succeed, please share your elasticsearch.yml and your logs (formatted as I explained before - you did it wrong again in your first post)

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