Reputation: 343
I'm working on localhost, and in order to understand what cluster is and what a node is, i want to have two nodes on my localhost.
just to make it clear: when I lunch the elasticsearch from bin/elasticsear, i'm luching a cluster, right?
if yes, then where is the node?
and how can I have two nodes on my cluster?
You may ask why do I need that?
It is because, as you may know, each index in an elasticsearch cluster has shads. default is 5 shards for one index, and default is each index has 1 replica, so each index be default has 10 shards, 5 for original data, and 5 for replica. in elasticsearch, it is impossible to put the replica's shards and the original shards on the same node. thus, in my case, i have one cluster running 5 original shards for each index, but i don't have the 5 replica's shads. that's why my index status is yellow (not green, not red), i want it to be green, thus i need another node in my cluster to put the shards, but i just have one elasticsearch server (localhost), that's why i need another node on my localhost elasticsearch server
Upvotes: 0
Views: 1047
Reputation: 7649
Whenever you start elasticsearch server a master node
gets up by default.In order to run another node, just go to another terminal and start your elastic-search server again.
Make sure that:
discovery.zen.ping.multicast.enabled: true
in elasticsearch.yml
.Since elasticsearch is distributed
in nature, the newly added instance will be automatically detected by the already existing node(s).You can verify this from the terminal.
Suppose the name of existing node was node1
and newly added node is node2
.
On the terminal where node1
was running you will see this message:
[node1] added [node2]
On the terminal where node2
has been started you will see message:
[node2] detected_master [node1]
Both the nodes detected each other automatically. You can run following query in sense to check the nodes running:
GET /_cluster/state
This will list all the nodes
Upvotes: 0