Dav*_* J. 12 macos elasticsearch
我使用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
现在我有"Korvus" http://localhost:9200/和"Iron Monger" http://localhost:9201/.活泉.但是,我没有看到任何迹象表明他们彼此了解.如何将它们相互连接/引入?
注意:我读过Zen Discovery,但感觉不到开悟.
这是我的两个节点:
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
}
Run Code Online (Sandbox Code Playgroud)
为了澄清,我的问题不是如何通过设置来"忽略"问题index.number_of_replicas: 0.我想连接多个节点.
我刚发布了一个包含elasticsearch.yml和elasticsearch_david.log的双重要点.在我看来,两个节点都称自己为'主'.那是我应该期待的吗?
小说继续!:)如果我从所有外部网络断开我的Mac,然后重新启动节点,那么他们会找到对方.双击.这让我觉得问题在于我的网络/多播配置.目前我在我的配置中有这个:network.host: 127.0.0.1.也许这不正确?
Dav*_* J. 19
解决了.不要用network.host: 127.0.0.1.将该行留下注释,以便自动派生.
默认elasticsearch.yml是正确的.阿由自制安装构造的调整指定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
Run Code Online (Sandbox Code Playgroud)
imo*_*tov 13
正确地注意到,由于您创建了一个包含副本的索引但群集中只有一个节点,因此群集变为黄色.解决此问题的一种方法是在第二个节点上分配它们.另一种方法是关闭复制品.可以在创建索引期间指定副本数.以下命令将创建一个名为new-index-name1 shard且没有副本的新索引.
curl -XPUT 'localhost:9200/new-index-name' -d '
{
"settings": {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
}
}
}
'
Run Code Online (Sandbox Code Playgroud)
在使用Indices Update Settings API创建索引之后,还可以更改副本数.对于群集中的所有索引,以下命令将将副本数更改为0:
curl -XPUT 'localhost:9200/_settings' -d '
{
"index" : {
"number_of_replicas" : 0
}
}
'
Run Code Online (Sandbox Code Playgroud)
您可以通过运行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
}
Run Code Online (Sandbox Code Playgroud)
这一行"number_of_data_nodes" : 2,表明我的集群由两个节点组成,这意味着他们找到了彼此.您还可以运行" 节点信息"命令以查看群集包含的节点:
curl "http://localhost:9200/_cluster/nodes?pretty=true"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16855 次 |
| 最近记录: |