1 Overview
Reprinted: https://www.cnblogs.com/sanduzxcvbnm/p/12076600.html
Elastic: How to simulate multiple nodes simultaneously on one machine
/bin/elasticsearch -E node.name=node1 -E cluster.name=my-application -E path.data=node1_data
/bin/elasticsearch -E node.name=node2 -E cluster.name=my-application -E path.data=node2_data
/bin/elasticsearch -E node.name=node3 -E cluster.name=my-application -E path.data=node3_data -d
Step 1: Download and install Elasticsearch
Don't run Elasticsearch yet.
Step 2: Run Elasticsearch instance
Now we will show how to start your first instance. To do this, open a terminal and go to the installation directory of Elasticsearch. Then start the node named node1 with the following command:
./bin/elasticsearch -E node.name=node1 -Enode.max_local_storage_nodes=3
This command uses option -E to set the parameter node.name to node1. To start the other two instances is very simple: you just need to use the same command, but use another node name.
On the new terminal, start the node named node2 with the following command:
./bin/elasticsearch -E node.name=node2 -Enode.max_local_storage_nodes=3
On the new terminal, start the node named node3 with the following command:
./bin/elasticsearch -E node.name=node3 -Enode.max_local_storage_nodes=3
You can use curl and the _cat /nodes endpoint to check a cluster of 3 nodes:
curl -X GET http://localhost:9200/_cat/nodes?v
or:
curl -u elastic:123123 -X GET http://localhost:9200/_cat/nodes?v
If you have set a password for your cluster. Here elastic:123123 is the username and password of the cluster.
The results displayed are:
curl -X GET http://localhost:9200/_cat/nodes?v
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
127.0.0.1 10 77 6 2.31 dilm - node2
127.0.0.1 18 77 6 2.31 dilm - node3
127.0.0.1 15 77 6 2.31 dilm * node1
From the above we can see that there are three running nodes. Among them, node1 is a master node (containing a *). The above dilm means:
d: data node
i: ingest node
m: master node
l: machine learning node