Cluster Red - 索引中未分配的分片

时间:2018-01-02 09:11:21

标签: elasticsearch elasticsearch-5

我的星团突然变红了。因为索引分片分配失败。我跑的时候

GET /_cluster/allocation/explain
{
  "index": "my_index",
  "shard": 0,
  "primary": true
}

输出:

{
  "shard": {
    "index": "twitter_tracker",
    "index_uuid": "mfXc8oplQpq2lWGjC1TxbA",
    "id": 0,
    "primary": true
  },
  "assigned": false,
  "shard_state_fetch_pending": false,
  "unassigned_info": {
    "reason": "ALLOCATION_FAILED",
    "at": "2018-01-02T08:13:44.513Z",
    "failed_attempts": 1,
    "delayed": false,
    "details": "failed to create shard, failure IOException[failed to obtain in-memory shard lock]; nested: NotSerializableExceptionWrapper[shard_lock_obtain_failed_exception: [twitter_tracker][0]: obtaining shard lock timed out after 5000ms]; ",
    "allocation_status": "no_valid_shard_copy"
  },
  "allocation_delay_in_millis": 60000,
  "remaining_delay_in_millis": 0,
  "nodes": {
    "n91cV7ocTh-Zp58dFr5rug": {
      "node_name": "elasticsearch-24-384-node-1",
      "node_attributes": {},
      "store": {
        "shard_copy": "AVAILABLE"
      },
      "final_decision": "YES",
      "final_explanation": "the shard can be assigned and the node contains a valid copy of the shard data",
      "weight": 0.45,
      "decisions": []
    },
    "_b-wXdjGRdGLEtvY76PDSA": {
      "node_name": "elasticsearch-24-384-node-2",
      "node_attributes": {},
      "store": {
        "shard_copy": "NONE"
      },
      "final_decision": "NO",
      "final_explanation": "there is no copy of the shard available",
      "weight": 0,
      "decisions": []
    }
  }
}

解决方案是什么?这发生在我的生产节点中。我的弹性搜索版本5.0。我有两个节点

2 个答案:

答案 0 :(得分:1)

这是每个Elastic Cluster开发人员都会碰到的一个问题:)

Safeway重路由红色索引。

curl -XPOST 'localhost:9200/_cluster/reroute?retry_failed

此命令将花费一些时间,但是在数据传输时不会出现分配错误。

这里是问题的解释更广泛的enter link description here

答案 1 :(得分:0)

我用以下命令解决了我的问题。

curl -XPOST 'localhost:9200/_cluster/reroute?pretty' -d '{
    "commands" : [ {
        "allocate_stale_primary" :
            {
              "index" : "da-prod8-other", "shard" : 3,
              "node" : "node-2-data-pod",
              "accept_data_loss" : true
            }
        }
    ]
}'

所以在这里你可能会丢失数据。对我来说效果很好。运行命令时非常激动人心。幸运的是它运作良好。有关详细信息,请enter link description here检查此主题。