1. 程式人生 > >elasticsearch 集群indices 分片狀態INITIALIZING

elasticsearch 集群indices 分片狀態INITIALIZING

commands arch 集群 cas 故障 from cati 服務 題解

elasticsearch 集群indices 分片狀態INITIALIZING,集群狀態為: yellow

故障現象

GET /_cat/shards/7a_cool

7a_cool 5  r STARTED      4583018 759.4mb 10.2.4.21 pt01-pte-10-2-4-21
7a_cool 17 r INITIALIZING                 10.2.4.22 pt01-pte-10-2-4-22  《==異常分片

解決辦法

1:關閉異常分片主機es 服務;

        登陸pt01-pte-10-2-4-22 主機  ,/etc/init.d/elasticsearch  stop ,發現分片自動遷移至其它主機,但是狀態還是在初始化狀態,問題依舊存在;   

2:指定分片做主機遷移,

POST /_cluster/reroute
{
  "commands": [
    {
      "move": {
        "index": "7a_cool",
        "shard": 17,
        "from_node": "pt01-pte-10-2-4-22",
        "to_node": "pt01-pte-10-2-4-25"
      }
    }
  ]
}

發現報錯:報錯信息如下:

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "[move_allocation] can‘t move 17, shard is not started (state = INITIALIZING]"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "[move_allocation] can‘t move 17, shard is not started (state = INITIALIZING]"
  },
  "status": 400
}
    以上信息顯示, state = INITIALIZING ,不能移動。   

3:修改分片副本數量

    首先修改indices 副本數為0 

    此時集群開始調整集群分片,調整完成後集群狀態變成:green
PUT 7a_cool/_settings
{
  "index": {
        "number_of_replicas": "0"
        }
}

然後再修改集群indices狀態為1

PUT 7a_cool/_settings
{
  "index": {
        "number_of_replicas": "1"
        }
}
集群會再次調整副本數量,調整完成後集群狀態依然是:green ,問題解決。

elasticsearch 集群indices 分片狀態INITIALIZING