Dmitry Lovermann
Dmitry Lovermann

Reputation: 290

Choosing configuration file to start elastic cluster

I have two-node cluster on one machine and one config file (elasticsearch.yml). Is it possible to create another .yml-config file and start every instance with different config-file? For example, i want run cluster on two ports (localhost:9200 and localhost:9201) on the same time.

I can't find command-line API for starting elastic-cluster (config-file as an argument?).

Upvotes: 6

Views: 12830

Answers (3)

Vlad
Vlad

Reputation: 1112

A newer approach starting from ES 6 release for launching multiple instances based on the same ES installation is to have multiple config folders and declaring path variable before startup execution

ES_PATH_CONF=/apps/my-es/conf/node-1 ./elasticsearch
ES_PATH_CONF=/apps/my-es/conf/node-2 ./elasticsearch

To launch as daemon include -d and -p <pidName> for defining pid name

ES_PATH_CONF=/apps/my-es/conf/node-1 ./elasticsearch -d -p es_node1_pid
ES_PATH_CONF=/apps/my-es/conf/node-2 ./elasticsearch -d -p es_node2_pid

here is a reference on ES docs: https://www.elastic.co/guide/en/elasticsearch/reference/current/settings.html

Upvotes: 5

Val
Val

Reputation: 217274

You should be able to start your second ES instance with the -Epath.conf setting on the command line and point to another folder where you have your second elasticsearch.yml configuration file

./bin/elasticsearch -Epath.conf=/path/to/my/second/config/

Upvotes: 10

user3775217
user3775217

Reputation: 4803

it has to be more than command line.You should look at installing two instance of elasticsearch service configured to listen at two different ports.

If you are on ubuntu OS - you can have two init.d scripts for both two instances 1)In the init.d script set the name of the process that run the service like for two cluster set elasticsearch_node_1 and elasticsearch_node_2 2)In the same file configure the path to logs, data and configuration file to two seperate locations for both the init files. untill here you will have two services running on the same machine

Maybe you don't want to run the instances as OS service then i recommend checking this link

Two nodes on same machine

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

3)now modify the elasticsearch.yml files for each instance pointed by init script. change http.port to any port you want to run your instance on. for discovery host1 and host2 will be same, only you have to change port to another node for each instance and accordingly set path.data and path.logs for each instance

http.port: 9200
discovery.zen.ping.unicast.hosts: ["host1", "host2:port"]
path.data: /path/to/data
path.logs: /path/to/logs

Upvotes: 0

Related Questions