mCs
mCs

Reputation: 2901

How to start many ElasticSearch nodes in one Machine

I tried to start each node with one machine and one cluser (on localhost only - testing purpose) with the following command:

sudo /usr/share/elasticsearch/bin/elasticsearch
 -Des.node.data=false 
 -Des.node.master=true 
 -Des.node.name=NoData --default.path.conf=/etc/elasticsearch/

However, I can't start even one node becouse I keep getting this error even when starting the first node:

> Exception in thread "main" java.lang.RuntimeException: don't run
> elasticsearch as root.    at
> org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:93)
>   at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:144)
>   at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270)   at
> org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
> Refer to the log for complete error details. 

How to start many ES nodes on one machine?

(ES is installed form official deb repo of ES)

EDIT I wanted to run it like below

$ bin/elasticsearch -Des.config=$ES_HOME/config/elasticsearch.1.yml
$ bin/elasticsearch -Des.config=$ES_HOME/config/elasticsearch.2.yml
$ bin/elasticsearch -Des.config=$ES_HOME/config/elasticsearch.testNoData.yml

BUT TWO PROBLEMS

  1. It does NOT work becouse of the above.
  2. Still not sure what should be within those 3 yml files?

Upvotes: 1

Views: 1704

Answers (2)

Val
Val

Reputation: 217254

If you want to start many nodes for testing purposes, I strongly recommend to use the esvm tool.

That tool is specifically designed for rapidly testing your code against different ES versions running on one or many nodes. For instance, you can start a 5-node cluster (2 master + 3 data) very easily using this configuration file:

{
  "clusters": {
    "2m3d": {
      "plugins": ["mobz/elasticsearch-head"],
      "nodes": [
        {
          "cluster": { "name": "2m3d" },
          "node": { "name": "master-1", "data": false, "master": true }
        },
        {
          "cluster": { "name": "2m3d" },
          "node": { "name": "master-2", "data": false, "master": true }
        },
        {
          "cluster": { "name": "2m3d" },
          "node": { "name": "data-1", "data": true, "master": false }
        },
        {
          "cluster": { "name": "2m3d" },
          "node": { "name": "data-2", "data": true, "master": false }
        },
        {
          "cluster": { "name": "2m3d" },
          "node": { "name": "data-3", "data": true, "master": false }
        }
      ]
    }
  }
}

The above cluster can be launched very simply by running

> esvm 2m3d

Upvotes: 3

Yaron Idan
Yaron Idan

Reputation: 6765

  1. In order to start more than one ES node on your server you will have to set different configuration for each node (different port, different data folder and so on). This will probably involve some hard work and is not recommended since different ES nodes will probably still conflict and fail.

  2. The error clearly says you should not run Elasticsearch as root, and you are running it with sudo - which makes it run as root. Try running ES by launching the its service, by using the command - sudo service elasticsearch start. This will start the ES daemon with proper configuration.

Upvotes: 1

Related Questions