在升級(jí)阿里云Elasticsearch實(shí)例版本前,您需要通過(guò)升級(jí)檢查,檢查集群狀態(tài)是否正常、是否存在不兼容的配置等,并進(jìn)行調(diào)整。本文介紹在版本升級(jí)前需要完成的人工檢查、集群狀態(tài)檢查和系統(tǒng)兼容性檢查,以及兼容性檢查失敗時(shí)的調(diào)整方法。

背景信息

  • 升級(jí)版本的具體操作,請(qǐng)參見(jiàn)升級(jí)版本
  • 本文的命令都可在Kibana控制臺(tái)上執(zhí)行,關(guān)于如何登錄Kibana控制臺(tái),請(qǐng)參見(jiàn)登錄Kibana控制臺(tái)

人工檢查

在執(zhí)行升級(jí)版本操作前,您必須手動(dòng)完成以下檢查:

  • 執(zhí)行以下命令,檢查集群中是否存在close狀態(tài)的索引。
    GET _cat/indices?v
    檢查集群中close狀態(tài)的索引

    如果存在,需要執(zhí)行以下命令將索引狀態(tài)暫時(shí)設(shè)置為open,以便進(jìn)行升級(jí)檢查。

    POST test/_open
  • 如果您需要更新升級(jí)內(nèi)核補(bǔ)丁,需要檢查對(duì)應(yīng)實(shí)例是否存在可更新的內(nèi)核補(bǔ)丁,存在才可更新。
    可在實(shí)例的基本信息頁(yè)面查看,如下圖所示。有可更新的內(nèi)核版本
  • 檢查是否通過(guò)客戶端連接了待升級(jí)的集群。如果是,您需要更新客戶端版本,確保客戶端與集群版本的兼容性。關(guān)于兼容性的詳細(xì)信息,請(qǐng)參見(jiàn)Compatibility
對(duì)于將5.x版本實(shí)例升級(jí)至6.x版本的情況,除了以上檢查外,您還需要再完成以下檢查:
  • 將5.x版本中的多type索引拆分為單type索引。

    Elasticsearch從6.x版本開(kāi)始,不再支持一個(gè)索引多個(gè)type。而升級(jí)后,在5.x版本中創(chuàng)建的多type索引,在6.x版本中依然可以正常寫入,但是在6.x版本中新建多type索引時(shí)會(huì)報(bào)錯(cuò)。因此,建議在升級(jí)前,按照官方標(biāo)準(zhǔn),將5.x版本中的多type索引拆分為單type索引后,再進(jìn)行升級(jí)。具體操作步驟,請(qǐng)參見(jiàn)基于reindex實(shí)現(xiàn)低版本多type數(shù)據(jù)遷移

  • 執(zhí)行以下命令,檢查集群中是否配置了跨集群訪問(wèn)。開(kāi)啟時(shí),您可以在返回結(jié)果中看到search.remote屬性的配置,且不為null。
    GET _cluster/settings
    如果配置了跨集群訪問(wèn),需要執(zhí)行以下腳本,在升級(jí)前取消該項(xiàng)配置,待升級(jí)后重新配置。
    PUT _cluster/settings
    {
      "persistent": {
        "search.remote.*": null
      },
      "transient": {
        "search.remote.*": null
      }
    }
    重要 升級(jí)后重新配置跨集群訪問(wèn)時(shí)需要注意:Elasticsearch 5.x版本中使用的配置參數(shù)是search.remote,而6.x版本中使用的是cluster.remote

集群狀態(tài)檢查

在進(jìn)行升級(jí)操作時(shí),阿里云Elasticsearch會(huì)自動(dòng)檢查集群是否處于正常狀態(tài),以及負(fù)載是否處于正常水位。只有當(dāng)兩者都正常時(shí),才可以對(duì)實(shí)例進(jìn)行升級(jí)。您也可以在進(jìn)行升級(jí)操作前,參考以下列表人工檢查集群狀態(tài),確保操作可以順利進(jìn)行。
校驗(yàn)項(xiàng) 正常狀態(tài)
集群健康度 集群狀態(tài)正常(綠色)。
JVM使用率 集群JVM使用率低于75%。
磁盤使用率 節(jié)點(diǎn)的磁盤使用率低于cluster.routing.allocation.disk.watermark.low屬性設(shè)置的值。
副本個(gè)數(shù)
  • 所有索引都存在副本。
  • 對(duì)于多可用區(qū)實(shí)例,在變更時(shí),需要確保集群中任意一個(gè)索引的副本數(shù)都小于可用區(qū)數(shù)。待變更完成后,您可以根據(jù)業(yè)務(wù)手動(dòng)增加副本數(shù)。詳細(xì)信息請(qǐng)參見(jiàn)索引模板
快照 集群在最近1個(gè)小時(shí)內(nèi)完成過(guò)快照。
自定義插件 集群中不存在阿里云Elasticsearch預(yù)裝之外的插件。
可用區(qū)ECS資源校驗(yàn) 可用區(qū)中ECS實(shí)例的庫(kù)存充足。
說(shuō)明 由于版本升級(jí)采用了先增加高版本節(jié)點(diǎn),再將低版本節(jié)點(diǎn)的數(shù)據(jù)遷移到高版本節(jié)點(diǎn),最后刪除低版本節(jié)點(diǎn)的方式,因此升級(jí)前需要校驗(yàn)可用區(qū)中ECS實(shí)例的庫(kù)存。
YML文件 高版本的集群可以兼容低版本的配置。

配置兼容檢查

如果升級(jí)的目標(biāo)版本為6.x,在進(jìn)行升級(jí)操作時(shí),阿里云Elasticsearch會(huì)自動(dòng)檢查集群不同版本之間是否存在不兼容的配置。如果您使用了這些配置,升級(jí)后,集群服務(wù)可能會(huì)受到影響。您也可以在進(jìn)行升級(jí)操作前,使用GET _cluster/settingsGET */_settings?flat_settings=true命令查看集群中是否存在下表中的配置,確保升級(jí)操作可以順利進(jìn)行。
重要 對(duì)于索引模板級(jí)別類配置,當(dāng)模板中存在這些配置時(shí),在版本升級(jí)后,對(duì)應(yīng)模板將無(wú)法用于創(chuàng)建新索引。
序號(hào) 配置級(jí)別 配置信息 配置參數(shù)
1 集群級(jí)別 集群快照設(shè)置(Snapshot settings) cluster.routing.allocation.snapshot.relocation_enabled
2 集群存儲(chǔ)限流設(shè)置(Store throttling settings) indices.store.throttle.typeindices.store.throttle.max_bytes_per_sec
3 索引級(jí)別 索引相似性設(shè)置(Similarity settings) index.similarity.base
4 索引影子副本設(shè)置(Shadow replicas settings) index.shared_filesystemindex.shadow_replicas
5 索引存儲(chǔ)設(shè)置(Index store settings) index.store.type
6 索引存儲(chǔ)限流設(shè)置(Index store throttling settings) index.store.throttle.typeindex.store.throttle.max_bytes_per_sec
7 索引Mapping參數(shù)include_in_all設(shè)置 include_in_all
說(shuō)明 該配置在6.0版本之后創(chuàng)建的索引中無(wú)法使用,但在5.x版本中創(chuàng)建的包含此配置的索引,在升級(jí)到6.x版本后,可以兼容。
8 索引創(chuàng)建版本設(shè)置 index.version.created
說(shuō)明 該配置表示不允許跨主版本升級(jí)索引。例如,無(wú)法將在5.x版本創(chuàng)建的索引直接升級(jí)到7.x版本,需要將失敗的索引通過(guò)reindex遷移到新索引并刪除后,再進(jìn)行升級(jí)。
9 索引模板級(jí)別 索引模板相似性設(shè)置(Similarity settings) index.similarity.base
10 索引模板影子副本設(shè)置(Shadow replicas settings) index.shared_filesystemindex.shadow_replicas
11 索引模板存儲(chǔ)設(shè)置(Index store settings) index.store.type
12 索引模板存儲(chǔ)限流設(shè)置(Index store throttling settings) index.store.throttle.typeindex.store.throttle.max_bytes_per_sec
13 索引模板 Mapping參數(shù)include_in_all include_in_all
14 索引模板Mapping元字段_all _all
15 索引模板Mapping包含多個(gè)type 無(wú)
說(shuō)明 檢查索引Mapping中是否包含多個(gè)type。
說(shuō)明
  • 以上配置參數(shù)在6.0版本開(kāi)始被廢棄,詳細(xì)信息請(qǐng)參見(jiàn)Breaking changes in 6.0
  • 以上檢查項(xiàng)均為CRITICAL(錯(cuò)誤)級(jí)別。出現(xiàn)一次,即表示檢查失敗無(wú)法升級(jí),此類型檢查項(xiàng)對(duì)應(yīng)配置在目標(biāo)版本無(wú)法兼容,您需要參見(jiàn)配置不兼容的調(diào)整方法調(diào)整集群配置,并重新檢查。而對(duì)于WARNING(警告)級(jí)別的檢查項(xiàng),表示檢查失敗時(shí)仍可以升級(jí),即此類型檢查項(xiàng)對(duì)應(yīng)配置在升級(jí)后將被忽略。

配置不兼容的調(diào)整方法

如果兼容性檢查不通過(guò),您可以通過(guò)以下方式調(diào)整集群:
  • 集群級(jí)別

    當(dāng)以下配置不兼容時(shí),您可以取消對(duì)應(yīng)配置進(jìn)行調(diào)整。

    配置信息 取消配置命令
    集群快照設(shè)置(Snapshot settings)
    PUT _cluster/settings
    {
      "persistent": {
        "cluster.routing.allocation.snapshot.relocation_enabled": null
      },
      "transient": {
        "cluster.routing.allocation.snapshot.relocation_enabled": null
      }
    }
    集群存儲(chǔ)限流設(shè)置(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
      }
    }
  • 索引級(jí)別

    當(dāng)以下配置不兼容時(shí),您可以取消對(duì)應(yīng)配置進(jìn)行調(diào)整。

    配置信息 取消配置命令 相關(guān)說(shuō)明
    索引相似性設(shè)置(Similarity settings)
    PUT test_index/_settings
    {
       "index.similarity.base.*": null
    }
    這些配置需要關(guān)閉索引后修改,關(guān)閉后,您將無(wú)法對(duì)索引進(jìn)行讀寫操作。修改完成后,您可以再次打開(kāi)對(duì)應(yīng)索引。以test_index索引為例,關(guān)閉和打開(kāi)索引的命令如下:
    • 關(guān)閉索引
      POST test_index/_close
    • 打開(kāi)索引
      POST test_index/_open
    索引影子副本設(shè)置(Shadow Replicas settings)
    PUT test_index/_settings
    {
        "index.shared_filesystem": null,
        "index.shadow_replicas": null
    }
    索引存儲(chǔ)設(shè)置(Index Store settings)
    PUT test_index/_settings
    {
       "index.store.type": null
    }
    索引存儲(chǔ)限流設(shè)置(Index Store throttling settings)
    PUT test_index/_settings
    {
      "settings": {
        "index.store.throttle.type": null,
        "index.store.throttle.max_bytes_per_sec": null
      }
    }
    無(wú)
    說(shuō)明 對(duì)于已創(chuàng)建的包含索引Mapping參數(shù)include_in_all的索引,升級(jí)后可以兼容,無(wú)需修復(fù)。
  • 索引模板級(jí)別

    以下以test_template索引模板為例,介紹處理索引模板類型的檢查項(xiàng)未通過(guò)檢查的調(diào)整方法:

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

      根據(jù)以下結(jié)果發(fā)現(xiàn)test_template中存在的不兼容配置包括:索引模板存儲(chǔ)設(shè)置(Index store settings)、索引模板Mapping元字段_all和索引模板Mapping參數(shù)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. 執(zhí)行以下命令,刪除模板中不兼容的配置,并更新模板。
      PUT _template/test_template
      {
         "order": 0,
         "template": "test_*",
         "settings": {
         },
         "mappings": {
           "test_type": {
             "properties": {
               "test_field": {
                 "type": "text"
               }
             }
           }
         },
         "aliases": {}
      }