簡體   English   中英

如何為單集群(獨立集群)配置單節點 ElasticSearch

[英]How to config Single node for Single Cluster (Standalone Cluster) ElasticSearch

我在本地機器上安裝了彈性搜索,我想將其配置為集群中唯一的單個節點(獨立服務器)。 這意味着每當我創建一個新索引時,它只會對我的服務器可用。 其他服務器將無法訪問它。

我目前的情況是這些索引可用於其他服務器(服務器在集群中形成),並且它們可以對我的索引進行任何更改。 但我不想要。

我瀏覽了其他一些博客,但沒有得到最佳解決方案。 所以你能告訴我同樣的步驟嗎?

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

以下是 ElasticSearch 5 的相關信息:

根據更新日志,以便於ES 5需要添加本地模式transport.type: localelasticsearch.yml而不是node.local: true

如果您打算在單個節點上運行 Elasticseach 並能夠將其綁定到公共 IP,那么兩個重要設置是:

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

如果你在代碼中使用的網絡傳輸,這是行不通的,因為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

我不確定這是否會阻止其他節點發現您的節點; 我只需要它來影響同一網絡上具有相同設置的一組節點。

我想這樣做而不必在我的容器中寫入/覆蓋 elasticsearch.yml。 這里沒有配置文件

在啟動 elasticsearch 之前設置環境變量:

discovery.type=single-node

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

配置文件中,添加:

  • network.host: 0.0.0.0 [在網絡設置中]
  • discovery.type: single-node [在發現和集群形成設置中]

這可以解決您的問題:

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

使用 ES 版本 5 進行測試。

所有這些都沒有幫助我(遺憾的是我沒有閱讀 bhdrkn 的答案)。 對我有用的是每次我需要一個單獨的實例時更改 elasticsearch 的集群名稱,其中新節點不會通過多播自動添加。

只需更改 cluster.name: {{ elasticsearch.clustername }} 在 elasticsearch.yml 中,例如通過 Ansible。 這在構建開發、質量保證和生產(這是企業環境中的標准用例)等獨立階段時特別有用。

如果您使用 logstash 將數據放入 elasticsearch,請不要忘記將相同的集群名稱放入輸出部分,例如:

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

否則您的“logstash-*”-index 將無法正確構建...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM