全部產品
Search
文件中心

Elasticsearch:升級檢查

更新時間:Aug 22, 2026

在升級Elasticsearch執行個體版本前,您需要通過升級檢查,檢查叢集狀態是否正常、是否存在不相容的配置等,並進行調整。本文介紹在版本升級前需要完成的人工檢查、叢集狀態檢查和系統相容性檢查,以及相容性檢查失敗時的調整方法。

背景資訊

  • 升級版本的具體操作,請參見升級版本。

  • 本文的命令都可在Kibana控制台上執行,關於如何登入Kibana控制台,請參見登入Kibana控制台。

人工檢查

在執行升級版本操作前,您必須手動完成以下檢查:

  • 執行以下命令,檢查叢集中是否存在close狀態的索引。

    GET _cat/indices?v
    
    GET _cat/indices?v
    
    POST test/_open
    
    health status index
    green  open   .monitoring-es-6-2020.10.29
    green  open   .monitoring-logstash-6-2020.10.31
    green  open   filebeat-6.7.0-2020.10.31
    green  open   .monitoring-kibana-6-2020.10.27
           close  test
    

    如果存在,需要執行以下命令將索引狀態暫時設定為open,以便進行升級檢查。

    POST test/_open
  • 如果您需要更新升級核心補丁,需要檢查對應執行個體是否存在可更新的核心補丁,存在才可更新。

    可在執行個體的基本資料頁面查看。在版本行查看當前執行個體版本號碼(例如7.10.0),若版本號碼後顯示有可更新的核心補丁連結,表示存在可更新的核心補丁。

  • 檢查是否通過用戶端串連了待升級的叢集。如果是,您需要更新用戶端版本,確保用戶端與叢集版本的相容性。關於相容性的詳細資料,請參見Compatibility。

對於將5.x版本執行個體升級至6.x版本的情況,除了以上檢查外,您還需要再完成以下檢查:

  • 將5.x版本中的多type索引拆分為單type索引。

    Elasticsearch從6.x版本開始,不再支援一個索引多個type。而升級後,在5.x版本中建立的多type索引,在6.x版本中依然可以正常寫入,但是在6.x版本中建立多type索引時會報錯。因此,建議在升級前,按照官方標準,將5.x版本中的多type索引拆分為單type索引後,再進行升級。

  • 執行以下命令,檢查叢集中是否配置了跨叢集訪問。開啟時,您可以在返回結果中看到search.remote屬性的配置,且不為null。

    GET _cluster/settings

    如果配置了跨叢集訪問,需要執行以下指令碼,在升級前取消該項配置,待升級後重新設定。

    PUT _cluster/settings
    {
      "persistent": {
        "search.remote.*": null
      },
      "transient": {
        "search.remote.*": null
      }
    }
    重要

    升級後重新設定跨叢集訪問時需要注意:Elasticsearch 5.x版本中使用的配置參數是search.remote,而6.x版本中使用的是cluster.remote。

叢集狀態檢查

在進行升級操作時,Elasticsearch會自動檢查叢集是否處於正常狀態,以及負載是否處於正常水位。只有當兩者都正常時,才可以對執行個體進行升級。您也可以在進行升級操作前,參考以下列表人工檢查叢集狀態,確保操作可以順利進行。

校正項

正常狀態

叢集健康度

叢集狀態正常(綠色)。

JVM使用率

叢集JVM使用率低於75%。

磁碟使用率

節點的磁碟使用率低於cluster.routing.allocation.disk.watermark.low屬性設定的值。

副本個數

所有索引都存在副本。

快照

叢集在最近1個小時內完成過快照。

自訂外掛程式

叢集中不存在Elasticsearch預裝之外的外掛程式。

可用性區域ECS資源校正

可用性區域中ECS執行個體的庫存充足。

說明

由於版本升級採用了先增加高版本節點,再將低版本節點的資料移轉到高版本節點,最後刪除低版本節點的方式,因此升級前需要校正可用性區域中ECS執行個體的庫存。

YML檔案

高版本的叢集可以相容低版本的配置。

配置相容檢查

如果升級的目標版本為6.x,在進行升級操作時,Elasticsearch會自動檢查叢集不同版本之間是否存在不相容的配置。如果您使用了這些配置,升級後,叢集服務可能會受到影響。您也可以在進行升級操作前,使用GET _cluster/settings和GET*/_settings?flat_settings=true命令查看叢集中是否存在下表中的配置,確保升級操作可以順利進行。

重要

對於索引模板層級類配置,當模板中存在這些配置時,在版本升級後,對應模板將無法用於建立新索引。

序號

配置層級

配置資訊

配置參數

1

叢集層級

叢集快照設定(Snapshot settings)

cluster.routing.allocation.snapshot.relocation_enabled

2

叢集儲存限流設定(Store throttling settings)

indices.store.throttle.type、indices.store.throttle.max_bytes_per_sec

3

索引層級

索引相似性設定(Similarity settings)

index.similarity.base

4

索引陰影複製設定(Shadow replicas settings)

index.shared_filesystem、index.shadow_replicas

5

索引儲存設定(Index store settings)

index.store.type

6

索引儲存限流設定(Index store throttling settings)

index.store.throttle.type、index.store.throttle.max_bytes_per_sec

7

索引Mapping參數include_in_all設定

include_in_all

說明

該配置在6.0版本之後建立的索引中無法使用,但在5.x版本中建立的包含此配置的索引,在升級到6.x版本後,可以相容。

8

索引建立版本設定

index.version.created

說明

該配置表示不允許跨主要版本升級索引。例如,無法將在5.x版本建立的索引直接升級到7.x版本,需要將失敗的索引通過reindex遷移到新索引並刪除後,再進行升級。

9

索引模板層級

索引模板相似性設定(Similarity settings)

index.similarity.base

10

索引模板陰影複製設定(Shadow replicas settings)

index.shared_filesystem、index.shadow_replicas

11

索引模板儲存設定(Index store settings)

index.store.type

12

索引模板儲存限流設定(Index store throttling settings)

index.store.throttle.type、index.store.throttle.max_bytes_per_sec

13

索引模板 Mapping參數include_in_all

include_in_all

14

索引模板Mapping元欄位_all

_all

15

索引模板Mapping包含多個type

無

說明

檢查索引Mapping中是否包含多個type。

說明
  • 以上配置參數在6.0版本開始被廢棄,詳細資料請參見Breaking changes in 6.0。

  • 以上檢查項均為CRITICAL(錯誤)層級。出現一次,即表示檢查失敗無法升級,此類型檢查項對應配置在目標版本無法相容,您需要參見配置不相容的調整方法調整叢集配置,並重新檢查。而對於WARNING(警告)層級的檢查項,表示檢查失敗時仍可以升級,即此類型檢查項對應配置在升級後將被忽略。

配置不相容的調整方法

如果相容性檢查不通過,您可以通過以下方式調整叢集:

  • 叢集層級

    當以下配置不相容時,您可以取消對應配置進行調整。

    配置資訊

    取消配置命令

    叢集快照設定(Snapshot settings)

    PUT _cluster/settings
    {
      "persistent": {
        "cluster.routing.allocation.snapshot.relocation_enabled": null
      },
      "transient": {
        "cluster.routing.allocation.snapshot.relocation_enabled": null
      }
    }

    叢集儲存限流設定(Store throttling settings)

    PUT _cluster/settings
    {
      "persistent": {
        "indices.store.throttle.type": null,
        "indices.store.throttle.max_bytes_per_sec": null
      },
      "transient": {
        "indices.store.throttle.type": null,
        "indices.store.throttle.max_bytes_per_sec": null
      }
    }
  • 索引層級

    當以下配置不相容時,您可以取消對應配置進行調整。

    配置資訊

    取消配置命令

    相關說明

    索引相似性設定(Similarity settings)

    PUT test_index/_settings
    {
       "index.similarity.base.*": null
    }

    這些配置需要關閉索引後修改,關閉後,您將無法對索引進行讀寫操作。修改完成後,您可以再次開啟對應索引。以test_index索引為例,關閉和開啟索引的命令如下:

    • 關閉索引

      POST test_index/_close
    • 開啟索引

      POST test_index/_open

    索引陰影複製設定(Shadow Replicas settings)

    PUT test_index/_settings
    {
        "index.shared_filesystem": null,
        "index.shadow_replicas": null
    }

    索引儲存設定(Index Store settings)

    PUT test_index/_settings
    {
       "index.store.type": null
    }

    索引儲存限流設定(Index Store throttling settings)

    PUT test_index/_settings
    {
      "settings": {
        "index.store.throttle.type": null,
        "index.store.throttle.max_bytes_per_sec": null
      }
    }

    無

    說明

    對於已建立的包含索引Mapping參數include_in_all的索引,升級後可以相容,無需修複。

  • 索引模板層級

    以下以test_template索引模板為例,介紹處理索引模板類型的檢查項未通過檢查的調整方法:

    1. 使用GET _template/test_template命令擷取不相容的模板test_template。

      根據以下結果發現test_template中存在的不相容配置包括:索引模板儲存設定(Index store settings)、索引模板Mapping元欄位_all和索引模板Mapping參數include_in_all。

      {
       "test_template": {
         "order": 0,
         "template": "test_*",
         "settings": {
           "index": {
             "store": {
               "throttle": {
                 "max_bytes_per_sec": "100m"
               }
             }
           }
         },
         "mappings": {
           "test_type": {
             "_all": {
               "enabled": true
             },
             "properties": {
               "test_field": {
                 "type": "text",
                 "include_in_all": true
               }
             }
           }
         },
         "aliases": {}
       }
      }
    2. 執行以下命令,刪除模板中不相容的配置,並更新模板。

      PUT _template/test_template
      {
         "order": 0,
         "template": "test_*",
         "settings": {
         },
         "mappings": {
           "test_type": {
             "properties": {
               "test_field": {
                 "type": "text"
               }
             }
           }
         },
         "aliases": {}
      }