簡體   English   中英

使ElasticSearch集群變為綠色(OS X上的集群設置)

[英]Getting an ElasticSearch Cluster to Green (Cluster Setup on OS X)

使用Homebrew在Mac OS X上安裝了ElasticSearch 有用。 該集群以“綠色” 健康開始 但是,在添加數據之后,它已經變為“黃色”。

群集運行狀況為:綠色,黃色或紅色。 在分片級別,紅色狀態表示特定分片未在群集中分配,黃色表示分配了主分片但副本不分配,綠色表示分配了所有分片。 索引級別狀態由最差的分片狀態控制。 群集狀態由最差的索引狀態控制。

所以,我的副本分片沒有分配。 我該如何分配它們? (我在大聲思考。)

根據Shay的說法“我一直在獲得黃色的集群健康狀態” :“分片機制不會在同一節點上分配分片及其副本,但它會在同一節點上分配不同的分片。因此,您需要兩個分片節點獲得綠色的集群狀態。“

所以,我需要啟動第二個節點。 我是這樣做的:

cd ~/Library/LaunchAgents/
cp homebrew.mxcl.elasticsearch.plist homebrew.mxcl.elasticsearch-2.plist
# change line 8 to: homebrew.mxcl.elasticsearch-2
launchctl load -wF ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch-2.plist

現在我在http://localhost:9200/上的“Korvus”和http://localhost:9201/上的“Iron Monger”。 活泉。 但是,我沒有看到任何跡象表明他們彼此了解。 如何將它們相互連接/引入?

注意:我讀過Zen Discovery ,但感覺不到開悟。

更新2012-08-13美國東部時間下午11:30:

這是我的兩個節點:

curl "http://localhost:9200/_cluster/health?pretty=true"
{
  "cluster_name" : "elasticsearch_david",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 0,
  "active_shards" : 0,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0
}

curl "http://localhost:9201/_cluster/health?pretty=true"
{
  "cluster_name" : "elasticsearch_david",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 0,
  "active_shards" : 0,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0
}

更新2012-08-13美國東部時間下午11:35:

為了澄清,我的問題不是如何通過設置index.number_of_replicas: 0來“忽略”該問題。 我想連接多個節點。

更新2012-08-13美國東部時間下午11:48:

我剛發布了一個包含elasticsearch.yml和elasticsearch_david.log雙重要點 在我看來,兩個節點都稱自己為'主'。 那是我應該期待的嗎?

更新2012-08-14美國東部時間上午12:36:

小說繼續! :)如果我從所有外部網絡斷開我的Mac,然后重新啟動節點, 那么他們會找到對方。 雙擊。 這讓我覺得問題在於我的網絡/多播配置。 目前我在我的配置中有這個: network.host: 127.0.0.1 也許這不正確?

解決了。 不要使用network.host: 127.0.0.1 將該行留下注釋,以便自動派生。

默認的elasticsearch.yml是正確的。 Homebrew安裝程序的配置調整指定127.0.0.1環回接口:

# Set up ElasticSearch for local development:
inreplace "#{prefix}/config/elasticsearch.yml" do |s|
  # ...
  # 3. Bind to loopback IP for laptops roaming different networks
  s.gsub! /#\s*network\.host\: [^\n]+/, "network.host: 127.0.0.1"
end

在Homebrew問題跟蹤器上提出了一個問題

正確地注意到,由於您創建了一個包含副本的索引但群集中只有一個節點,因此群集變為黃色。 解決此問題的一種方法是在第二個節點上分配它們。 另一種方法是關閉復制品。 可以在創建索引期間指定副本數。 以下命令將創建一個名為new-index-name的新索引,其中包含1個分片但沒有副本。

curl -XPUT 'localhost:9200/new-index-name' -d '
{
    "settings": {
        "index" : {
            "number_of_shards" : 1,
            "number_of_replicas" : 0
        }
    }
}
'

在使用Indices Update Settings API創建索引之后,還可以更改副本數。 對於群集中的所有索引,以下命令將將副本數更改為0:

curl -XPUT 'localhost:9200/_settings' -d '
{
    "index" : {
        "number_of_replicas" : 0
    }
}
'

您可以通過運行cluster health命令驗證節點是否找到了彼此:

$ curl "http://localhost:9200/_cluster/health?pretty=true"
{
  "cluster_name" : "elasticsearch",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 2,
  "number_of_data_nodes" : 2,
  "active_primary_shards" : 30,
  "active_shards" : 55,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0
} 

這里的行"number_of_data_nodes" : 2,表示我的集群由兩個節點組成,這意味着它們找到了彼此。 您還可以運行“ 節點信息”命令以查看群集包含的節點:

curl "http://localhost:9200/_cluster/nodes?pretty=true"

我遇到了同樣的問題。 當外部網絡打開時,兩個節點(兩個elasticsearch實例運行不同的yml文件:elasticsearch - config = / usr / local / opt / elasticsearch / config / elasticsearch.yml elasticsearch --config = / usr / local / opt / elasticsearch / config / elasticsearch-1.yml)找不到對方,第一個實例處於黃色狀態,第二個實例沒有已分配的repllica。

解決方法:sudo route add -net 224.0.0.0/4 127.0.0.1

參考來自:

https://issues.jboss.org/browse/JGRP-1808

暫無
暫無

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

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