How to config Single node for Single Cluster (Standalone Cluster) ElasticSearch
Asked Answered
B

9

44

I installed elastic search in my local machine, I want to configure it as the only one single node in the cluster(Standalone Server). it means whenever I create a new index, it will only available to my server. It will not be accessible to other's server.

My current scenario these indexes are available to other servers (the servers are formed in a cluster), and they can make any changes to my indexes. But I don't want it.

I went through some other blogs but not getting best solution. So can you please let me know steps for same?

Babylonian answered 8/5, 2013 at 3:46 Comment(1)
Alternatively you can change the cluster name of your server.Burgher
B
75

I ve got the answer from http://elasticsearch-users.115913.n3.nabble.com/How-to-isolate-elastic-search-node-from-other-nodes-td3977389.html.

Kimchy : You set the node to local(true), this means it will not discover other nodes using network, only within the same JVM.

in elasticsearch/bin/elasticsearch.yml file

node.local: true # disable network

Updated for ES 7.x

in elasticsearch.yml

network.host: 0.0.0.0
discovery.type: single-node

and make sure you have cluster.initial_master_nodes off

# cluster.initial_master_nodes: ["node-1", "node-2"]

credited to @Chandan.

Babylonian answered 8/5, 2013 at 4:36 Comment(5)
Is this documented anywhere in the official reference?Cm
it is not documented, like a half of elasticsearch "features"Anjaanjali
node.local has been deprecated. See @felix-borzik answer below.Sleazy
See this response for ElasticSearch 5.0 and later.Stouffer
My version 6 installation does not recognize node.local at all.Dysarthria
T
26

In elasticsearch.yml

# Note, that for development on a local machine, with small indices, it usually
# makes sense to "disable" the distributed features:
#
index.number_of_shards: 1
index.number_of_replicas: 0

Use the same configuration in your code.

Also to isolate the node use node.local: true or discovery.zen.ping.multicast: false

Tenebrae answered 29/4, 2015 at 16:26 Comment(2)
See this response for ElasticSearch 5.0 and later.Stouffer
This fails in v6 and probably later. "index" settings must not be in the general settings file.Dysarthria
P
23

Here's relevant info for ElasticSearch 5:

According to changelog, to enable local mode on ES 5 you need to add transport.type: local to your elasticsearch.yml instead of node.local: true.

Patronize answered 23/7, 2017 at 9:0 Comment(2)
This response worked for me. Note that some of the older answers may be outdated. Here is a working link to the above mentioned changelogStouffer
local state has been removed from ES 6.0.x commitDarnel
P
23

If you intend to run Elasticseach on a Single Node and be able to bind it to public IP, two important settings are:

network.host: <PRIVATE IP OF HOST>
discovery.type: single-node
Positively answered 5/8, 2018 at 14:27 Comment(1)
This works on 7.x; thanks. elastic.co/guide/en/elasticsearch/reference/7.3/…Wheelwright
C
14

If you're using a network transport in your code, this won't work, as node.local gives you a LocalTransport only:

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-transport.html#_local_transport

The trick then is to set

discovery.zen.ping.multicast: false

in your elasticsearch.yml which will stop your node looking for any other nodes.

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-discovery-zen.html#multicast

I'm not sure if this prevents other nodes from discovering yours though; I only needed this to affect a group of nodes with the same settings on the same network.

Crustaceous answered 15/8, 2014 at 3:57 Comment(1)
See this response for ElasticSearch 5.0 and later.Stouffer
M
12

I wanted to do this without having to write/overwrite an elasticsearch.yml in my container. Here it is without a config file

Set an environment variable prior to starting elasticsearch:

discovery.type=single-node

https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html

Mackintosh answered 14/3, 2018 at 20:15 Comment(1)
This should now be the accepted answer. It is the documented solution to this problem from Elasticsearch docs: elastic.co/guide/en/elasticsearch/reference/current/… and elastic.co/guide/en/elasticsearch/reference/current/…Crescin
V
5

In the config file, add:

  • network.host: 0.0.0.0 [in Network settings]
  • discovery.type: single-node [in Discovery and Cluster formation settings]
Vitality answered 27/4, 2020 at 3:58 Comment(1)
This should now be the accepted answer. It is the documented solution to this problem from Elasticsearch docs: elastic.co/guide/en/elasticsearch/reference/current/… and elastic.co/guide/en/elasticsearch/reference/current/…Crescin
A
3

This solve your problem:

PUT /_all/_settings
{"index.number_of_replicas":0}

Tested with ES version 5.

Amygdalin answered 4/6, 2018 at 13:30 Comment(0)
M
1

All of these didn´t help me (and I sadly didn´t read the answer of bhdrkn). The thing that worked for me was to change elasticsearch´s cluster-name everytime I need to have a separate instance, where new nodes aren´t added automatically via multicast.

Just change cluster.name: {{ elasticsearch.clustername }} in elasticsearch.yml, e.g. via Ansible. This is particulary helpful, when building separate Stages like Dev, QA and Production (which is a standard usecase in enterprise-environments).

And if you´re using logstash to get your data into elasticsearch, don´t forget to put the same cluster-name into the output-section, like:

output {
    elasticsearch {
        cluster => "{{ elasticsearch.clustername }}"
    }
}

Otherwise your "logstash-*"-index will not be build correctly...

Momently answered 5/11, 2015 at 13:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.