在升级阿里云Elasticsearch实例版本前,您需要通过升级检查,检查集群状态是否正常、是否存在不兼容的配置等,并进行调整。本文介绍在版本升级前需要完成的人工检查、集群状态检查和系统兼容性检查,以及兼容性检查失败时的调整方法。

背景信息

  • 升级版本的具体操作,请参见升级版本
  • 本文的命令都可在Kibana控制台上执行,关于如何登录Kibana控制台,请参见登录Kibana控制台

人工检查

在执行升级版本操作前,您必须手动完成以下检查:

  • 执行以下命令,检查集群中是否存在close状态的索引。
    GET _cat/indices?v
    检查集群中close状态的索引

    如果存在,需要执行以下命令将索引状态暂时设置为open,以便进行升级检查。

    POST test/_open
  • 如果您需要更新升级内核补丁,需要检查对应实例是否存在可更新的内核补丁,存在才可更新。
    可在实例的基本信息页面查看,如下图所示。有可更新的内核版本
  • 检查是否通过客户端连接了待升级的集群。如果是,您需要更新客户端版本,确保客户端与集群版本的兼容性。关于兼容性的详细信息,请参见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/settingsGET */_settings?flat_settings=true命令查看集群中是否存在下表中的配置,确保升级操作可以顺利进行。
重要 对于索引模板级别类配置,当模板中存在这些配置时,在版本升级后,对应模板将无法用于创建新索引。
序号 配置级别 配置信息 配置参数
1 集群级别 集群快照设置(Snapshot settings) cluster.routing.allocation.snapshot.relocation_enabled
2 集群存储限流设置(Store throttling settings) indices.store.throttle.typeindices.store.throttle.max_bytes_per_sec
3 索引级别 索引相似性设置(Similarity settings) index.similarity.base
4 索引影子副本设置(Shadow replicas settings) index.shared_filesystemindex.shadow_replicas
5 索引存储设置(Index store settings) index.store.type
6 索引存储限流设置(Index store throttling settings) index.store.throttle.typeindex.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_filesystemindex.shadow_replicas
11 索引模板存储设置(Index store settings) index.store.type
12 索引模板存储限流设置(Index store throttling settings) index.store.throttle.typeindex.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": {}
      }