【问题标题】:How to config Single node for Single Cluster (Standalone Cluster) ElasticSearch如何为单集群(独立集群)配置单节点 ElasticSearch
【发布时间】:2013-05-08 03:46:06
【问题描述】:

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

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

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

【问题讨论】:

  • 您也可以更改服务器的集群名称。

标签: elasticsearch elastica


【解决方案1】:

我从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

为 ES 7.x 更新

在 elasticsearch.yml 中

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

并确保您已关闭 cluster.initial_master_nodes

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

归功于@Chandan。

【讨论】:

  • 这在官方参考文献中的任何地方都有记录吗?
  • 它没有记录,就像elasticsearch“功能”的一半
  • node.local 已被弃用。请参阅下面的@felix-borzik 答案。
  • 请参阅 this response 了解 ElasticSearch 5.0 及更高版本。
  • 我的第 6 版安装根本无法识别 node.local
【解决方案2】:

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

在您的代码中使用相同的配置。

还要隔离节点使用node.local: truediscovery.zen.ping.multicast: false

【讨论】:

  • 请参阅 this response 了解 ElasticSearch 5.0 及更高版本。
  • 这在 v6 和以后可能会失败。 “索引”设置不能在常规设置文件中。
【解决方案3】:

这里是 ElasticSearch 5 的相关信息:

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

【讨论】:

  • 这个回复对我有用。请注意,一些较旧的答案可能已过时。这是上述changelog的工作链接
  • local 状态已从 ES 6.0.x 中删除 commit
【解决方案4】:

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

network.host: <PRIVATE IP OF HOST>
discovery.type: single-node

【讨论】:

【解决方案5】:

如果您在代码中使用网络传输,这将不起作用,因为 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

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

【讨论】:

  • 请参阅 this response 了解 ElasticSearch 5.0 及更高版本。
【解决方案6】:

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

在启动 elasticsearch 之前设置环境变量:

discovery.type=single-node

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

【讨论】:

【解决方案7】:

config文件中,添加:

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

【讨论】:

【解决方案8】:

这解决了你的问题:

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

使用 ES 版本 5 测试。

【讨论】:

    【解决方案9】:

    所有这些都没有帮助我(遗憾的是我没有阅读 bhdrkn 的答案)。对我有用的是每次我需要一个单独的实例时更改elasticsearch的集群名称,其中新节点不会通过多播自动添加。

    只需在 elasticsearch.yml 中更改 cluster.name: {{ elasticsearch.clustername }},例如通过 Ansible。这在构建开发、QA 和生产等单独阶段(这是企业环境中的标准用例)时特别有用。

    如果您使用 logstash 将数据导入 elasticsearch,请不要忘记将相同的集群名称放入输出部分,例如:

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

    否则您的“logstash-*”-index 将无法正确构建...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-18
      • 2013-04-24
      • 2012-05-02
      • 2022-01-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多