ES集羣狀態yellow修復

查看集羣狀態

GET /_cluster/health

{
  "cluster_name" : "yzt-es-cluster",
  "status" : "yellow",
  "timed_out" : false,
  "number_of_nodes" : 20,
  "number_of_data_nodes" : 17,
  "active_primary_shards" : 1576,
  "active_shards" : 3044,
  "relocating_shards" : 5,  #正在重定位的分片的數量。
  "initializing_shards" : 2,  #正在初始化的分片數。
  "unassigned_shards" : 0, # 未分配的分片數。
  "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" : 99.93434011818779
}

查看問題索引

GET _cat/indices
yellow open comunication-iot-2022.06.08                        9bSOiO0-TbWTUzJmaiMihw 7 1 146014958      0  154.7gb   90.3gb

查看詳細的異常信息

GET /_cluster/allocation/explain

      "deciders" : [
        {
          "decider" : "shards_limit",
          "decision" : "NO",
          "explanation" : "too many shards [1] allocated to this node for index [comunication-iot-2022.06.08], index setting [index.routing.allocation.total_shards_per_node=1]"
        }
      ]

GET /comunication-iot-2022.06.08/_settings?pretty

        "routing" : {
          "allocation" : {
            "exclude" : {
              "box_type" : "cool"
            },
            "require" : {
              "box_type" : "large"
            },
            "total_shards_per_node" : "1"
          }
        },

Note:我們發現服務器集羣配置了total_shards_per_node這個屬性,並且該值的值爲1,也就驗證了上面的錯誤,該配置沒配置在elasticsearch.yml配置文件中,elasticsearch可以通過settings動態修改索引的分片和副本數等一些配置,我們發現集羣中total_shards_per_node配置了每個節點上允許的最多分片是2,然而我們在移動分片的時候需要某個節點在一段時間內允許同時存在三個分片,因此,我們需要修改該配置,修改此配置不需要重新啓動集羣,風險較小。

解決方案

PUT /comunication-iot-2022.06.08/_settings
{
  "index.routing.allocation.total_shards_per_node":2
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章