如何为单个群集(独立群集)ElasticSearch配置单个节点

cha*_* ly 34 elasticsearch elastica

我在本地计算机上安装了弹性搜索,我想将其配置为群集中唯一的单个节点(独立服务器).这意味着每当我创建一个新索引时,它只能用于我的服务器.其他服务器无法访问它.

我目前的情况是这些索引可供其他服务器使用(服务器在群集中形成),并且他们可以对我的索引进行任何更改.但我不想要它.

我浏览了一些其他博客,但没有得到最佳解决方案.那么请你告诉我相同的步骤吗?

cha*_* ly 57

我从http://elasticsearch-users.115913.n3.nabble.com/How-to-isolate-elastic-search-node-from-other-nodes-td3977389.html得到了答案.

Kimchy:您将节点设置为local(true),这意味着它不会发现使用网络的其他节点,只能在同一个JVM中.

在elasticsearch/bin/elasticsearch.yml文件中

node.local: true # disable network
Run Code Online (Sandbox Code Playgroud)

  • 这是否记录在官方参考的任何地方? (11认同)
  • 它没有记录,就像一半弹性搜索"功能" (7认同)
  • 不推荐使用node.local。请参阅下面的@ felix-borzik答案。 (2认同)

小智 24

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
Run Code Online (Sandbox Code Playgroud)

在代码中使用相同的配置.

也是为了隔离节点使用node.local: truediscovery.zen.ping.multicast: false

  • 不适用于ElasticSearch 5. (5认同)

Fel*_*zik 20

以下是ElasticSearch 5的相关信息:

根据更改日志,要在ES 5上启用本地模式,您需要添加transport.type: local到您的elasticsearch.yml而不是node.local: true.

  • `local`状态已从ES 6.0.x [commit]中删除(https://github.com/elastic/elasticsearch/commit/8a20dae6207e927576287c1742592d3e1b932065) (4认同)
  • 这个回复对我有用.请注意,一些较旧的答案可能已过时.以下是上述[changelog]的工作链接(https://www.elastic.co/guide/en/elasticsearch/reference/5.0/breaking_50_settings_changes.html#_node_settings) (2认同)

syn*_*ync 14

如果您在代码中使用网络传输,则无法使用,因为node.local仅为您提供LocalTransport:

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

诀窍是设置

discovery.zen.ping.multicast: false

在你的elasticsearch.yml将停止你的节点寻找任何其他节点.

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

我不确定这是否会阻止其他节点发现你的节点; 我只需要它来影响同一网络上具有相同设置的一组节点.


Cha*_*dan 10

如果打算在单个节点上运行Elasticseach并将其绑定到公共IP,则两个重要设置是:

network.host: <PRIVATE IP OF HOST>
discovery.type: single-node
Run Code Online (Sandbox Code Playgroud)


Joh*_*ner 7

我想这样做而不必在容器中写入/覆盖elasticsearch.yml。这里没有配置文件

在开始elasticsearch之前设置一个环境变量:

discovery.type=single-node

https://www.elastic.co/guide/zh-CN/elasticsearch/reference/current/docker.html

  • 现在这应该是公认的答案。这是 Elasticsearch 文档中针对此问题的记录解决方案:https://www.elastic.co/guide/en/elasticsearch/reference/current/bootstrap-checks.html 和 https://www.elastic.co/guide/ zh/elasticsearch/reference/current/bootstrap-checks.html#single-node-discovery (2认同)

小智 5

配置文件中,添加:

  • network.host: 0.0.0.0 [在网络设置中]
  • discovery.type: single-node [在发现和集群形成设置中]