How to config Single node for Single Cluster (Standalone Cluster) ElasticSearch

末鹿安然 提交于 2019-12-02 15:48:21

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

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

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.

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.

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

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

This solve your problem:

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

Tested with ES version 5.

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...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!