109

I have tried giving the following configurations in the elasticsearch.yaml file

network.host: aa.bbb.ccc.dd that being my IPv4 Address and http.port: 9200

The response to this is as follows when I try to run elasticsearch.bat on my windows machine:

the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

I am really not quite sure what to configure for the cluster initialization. The default values are discovery.seed_hosts: ["host1", "host2"] and cluster.initial_master_nodes: ["node-1", "node-2"]

Amit
  • 30,756
  • 6
  • 57
  • 88
SSB
  • 1,572
  • 2
  • 10
  • 12
  • How many nodes master nodes will you be setting up in your cluster? – Nishant Dec 16 '19 at 04:26
  • hay @OpsterESNinjaNishant , by n0,n1 and n2 you mean the IPV4 addresses of other client computers right ? – SSB Dec 16 '19 at 10:00
  • That can be value of `node.name` or IPv4 address of other nodes (elastic instances running on other machine) as well as of self (if it fall in the same category). – Nishant Dec 16 '19 at 11:36
  • @OpsterESNinjaNishant .. by 'elastic instances running on other machine' you mean the machine trying to access the server machine must also have elastic search running in it? – SSB Dec 17 '19 at 04:14
  • No, by 'elastic instances running on other machine' I mean all those server machines that have elastic running on them and which should be the part of same cluster. – Nishant Dec 17 '19 at 06:44
  • well I have just one that is the server. I want it to have remote access so others can access the search data. I tried what u told in the answer section, It dint work. – SSB Dec 17 '19 at 07:41
  • @OpsterElasticsearchNinja Sorry I dont use stackoverflow unless I have questions to ask. My apologies, I have upvoted your answer and marked it as the right one! Thanks! :) The issue was sort of resolved with the node configurations also but yes, your answer is definitely better and it works! so marked it right! – SSB Sep 12 '20 at 13:48
  • @SSB lf you notice this is one of the most popular question on elasticsearch tag and have been viewed ~11K times :) so having the good content on it, makes it more useful to community :) – Amit Sep 13 '20 at 04:51
  • 1
    @ElasticsearchNinja Its all about better answers. Whatever is the better answer is the answer. And again I am replying a whole month later because I don't login too often. Thanks for your answer! I am sure its helping many :) ;) – SSB Oct 21 '20 at 04:03
  • @SSB, you are right, and appreciate your actions :) – Amit Oct 21 '20 at 05:07
  • @ElasticsearchNinja could you please share your thoughts on this one ? https://stackoverflow.com/questions/65897286/can-i-filter-an-array-in-elastic – SSB Jan 26 '21 at 08:48

5 Answers5

216

In short, if you are running Elasticsearch locally(single node) or just with a single node on the cloud then just use below config in your elasticsearch.yml to avoid the production check, and to make it work, more info about this config in this SO answer:

discovery.type: single-node
Amit
  • 30,756
  • 6
  • 57
  • 88
  • 9
    This should be in the default configuration, commented at least. – AxelH Nov 20 '21 at 15:37
  • @Enerccio I am just curious why you think so, I am being programmer myself have opinion that great software product can't be made without great programmers :) – Amit Jun 22 '22 at 07:32
  • 1
    @Enerccio I am hoping you also faced the same issue which bring you to my answer :) hope it was helpful to you and resolved your issue :) – Amit Jun 22 '22 at 07:33
  • 2
    If you are trying to run elasticsearch from docker, like I did, then you should pass the next env variable - `-e "discovery.type=single-node"`. Taken from official docs https://hub.docker.com/_/elasticsearch – Vitaly Chura Dec 08 '22 at 04:54
  • 1
    Or you can add in docker yaml file: environment: discovery.type: single-node – Krunoslav Djakovic Jan 30 '23 at 10:37
  • 1
    What a legend, it's a shame it's not a comment in the configuration file to help – Oliver Aug 29 '23 at 15:02
  • @Oliver you are right, it should have been part of the configuration file – Amit Aug 31 '23 at 11:06
37

This is the configuration I did since I had only one machine that had the Elastic Search db in it (1 node Only).

node.data : true
network.host : 0.0.0.0
discovery.seed_hosts : []
cluster.initial_master_nodes : []
SSB
  • 1,572
  • 2
  • 10
  • 12
  • 3
    I've also tried with `discovery.seed_hosts : ["localhost", "127.0.0.1"]` and works great. Thanks – Martin Feb 11 '20 at 01:32
12

Elasticsearch 7 requires information to form a cluster. This is provided by the following two properties in elasticsearch.yml

cluster.initial_master_nodes : This is used to provide the initial set of nodes whose vote will be consider in master election process.

discovery.seed_hosts : This is used to provide the set of nodes which are master eligible. This should contain the name of all nodes which are master eligible.

So for example you are forming a cluster with three nodes : n0, n1, n2 which are master eligible then you config will look something like this:

cluster.initial_master_nodes: ["n0", "n1", "n2"]
discovery.seed_hosts: ["n0", "n1", "n2"]

Note: cluster.initial_master_nodes is used only once by elastic which is very first time of cluster formation.

For more detailed information read this guide.

Nishant
  • 7,504
  • 1
  • 21
  • 34
  • 6
    This answer is good general advice, but the answer to this specific question is to set `discovery.seed_hosts: ["aa.bbb.ccc.dd"]` or `discovery.seed_hosts: []`. Either is fine in a one-node cluster. – Dave Turner Dec 17 '19 at 08:13
  • 1
    @DaveTurner You are right. If the OP wants to have only one node cluster, but I never got a clear answer for that when I asked about the number of nodes. – Nishant Dec 17 '19 at 09:03
12
  • I have also faced the same issue with the elastic-search 7.6.2 version. The solution of the above-mentioned problem is, you just need to either add "discovery.seed_hosts : 127.0.0.1:9300" or set discovery.type: single-node in eleasticsearch.yml file to avoid the production use error.

  • Click here for discovery and cluster formation settings.

  • I have provided the detailed answer here.

Keshav Lodhi
  • 2,641
  • 2
  • 17
  • 23
0

I am adding my answer from docker container perspective. I initially tried running 3 nodes of elasticsearch in a same cluster and then tried running only 1 and faced same issue. To resolve, I deleted docker volumes. Please note, my docker elasticsearch nodes had no data so there was no data loss due to docker volume deletion.

https://discuss.elastic.co/t/how-my-config-file-should-be-on-publish-mode-with-a-single-node/189034