ElasticSearch具有两个节点(不同机器)的未分配分片,1个主控两个新实例

时间:2016-01-05 18:57:07

标签: elasticsearch

我启动了两个干净的elasticsearch实例(节点),没有数据,两个不同的机器(一个窗口,一个osx)。他们成功地发现了彼此。一个是node.master:false。两者都是node.data:true。我开始使用Kibana(创建te .kibana索引)并创建了一个测试索引(test),number_of_replicas = 1并且每个索引的状态和集群都是黄色的,我认为这是因为未分配的分片。我不知道如何解决未分配的分片。

在尝试强制复制分片时,我收到以下错误:

shard cannot be allocated on same node [tNUHIE6cTHO6h37P_s3m7w] it already exists on

一些细节:

_cat /节点ν:?

 host         ip       heap.percent ram.percent  load node.role master name              
192.168.1.99 192.168.1.99     2          81  1.95 d         *      node1     
192.168.1.2  192.168.1.2     13          46 -1.00 d         -      node2 

节点1:_cluster / health

{
 "cluster_name": "elasticsearch",
 "status": "yellow",
 "timed_out": false,
 "number_of_nodes": 2,
 "number_of_data_nodes": 2,
 "active_primary_shards": 6,
 "active_shards": 9,
 "relocating_shards": 0,
 "initializing_shards": 0,
 "unassigned_shards": 3,
 "delayed_unassigned_shards": 0,
 "number_of_pending_tasks": 0,
 "number_of_in_flight_fetch": 0,
 "task_max_waiting_in_queue_millis": 0,
 "active_shards_percent_as_number": 75

}

日志中没有错误但是如果我运行:

_cluster /重新路由?相当

{ "commands" : [ { "allocate" : { "index" : "test", "shard" : 1, "node" : "node2" } } ] 
}

我收到以下回复:

{ "error": {
  "root_cause": [
     {
        "type": "illegal_argument_exception",
        "reason": "[allocate] allocation of [test][1] on node { node2}{tNUHIE6cTHO6h37P_s3m7w}{192.168.1.2}{192.168.1.2:9300}{master=false} is not allowed, 
         reason: [YES(target node version [2.1.1] is same or newer than source node version [2.1.1])] 
         [YES(enough disk for shard on node, free: [111.6gb])]
         [YES(shard not primary or relocation disabled)]
         [YES(primary is already active)][YES(node passes include/exclude/require filters)]
         [YES(allocation disabling is ignored)]
         [NO(shard cannot be allocated on same node [tNUHIE6cTHO6h37P_s3m7w] it already exists on)]
         [YES(total shard limit disabled: [index: -1, cluster: -1] <= 0)][YES(below shard recovery limit of [2])][YES(no allocation awareness enabled)][YES(allocation disabling is ignored)]"
     }
     ],
  ...
  "status": 400
}

_cat /碎片·V

  index   shard prirep state      docs store ip           node          
 test      3     p      STARTED       0  130b 192.168.1.2 node2 
 test      3     r      UNASSIGNED                                          
 test      4     r      STARTED       0  130b 192.168.1.2  node2
 test      4     p      STARTED       0  130b 192.168.1.99 node1   
 test      1     p      STARTED       0  130b 192.168.1.2 node2
 test      1     r      UNASSIGNED                                       
 test      2     r      STARTED       0  130b 192.168.1.2  node2
 test      2     p      STARTED       0  130b 192.168.1.99 node1
 test      0     r      STARTED       0  130b 192.168.1.2 node2
 test      0     p      STARTED       0  130b 192.168.1.99 node1     
 .kibana 0    p      STARTED       1 3.1kb 192.168.1.2  node2 
 .kibana 0    r      UNASSIGNED        

对于新手的任何帮助都会在解决这个问题时受到赞赏。

1 个答案:

答案 0 :(得分:1)

您只能安全地重新路由副本分片。 GET _cat/shards?v清楚地显示test索引的id 1的分片(主要)已在node2上分配。您无法在已分配的同一节点上分配分片。这正是_cluster/reroute命令的输出告诉你的。而不是在node2上分配,而是在node1上分配。请尝试以下命令:

POST _cluster/reroute?explain
{
   "commands": [
      {
         "allocate": {
            "index": "test",
            "shard": 1,
            "node": "node1"
         }
      },
      {
         "allocate": {
            "index": "test",
            "shard": 2,
            "node": "node1"
         }
      }
   ]
}

这将尝试分配两个未分配的副本分片。另请注意explain选项。该命令的响应将给出一个详细的解释,说明命令成功或失败的原因,并且在调试时如果命令失败则非常方便。