elasticsearch - elasticsearch从1.7.x升级到5.2.x

标签 elasticsearch

将Elasticsearch从1.7升级到5.2的正确方法是什么?

我尝试先将其升级到2.4版本并完成重新索引过程,然后安装了elasticsearch v.5.2。在日志中启动v.5.2时,看到以下消息:

3) Error injecting constructor, java.lang.IllegalStateException: The index [[logstash-2017.01.15/tk1-FBLGTQGl0vVW1xxPpg]] was created with version [1.7.3] but the minimum compatible version is [2.0.0-beta1]. It should be re-indexed in Elasticsearch 2.x before upgrading to 5.2.2.

最佳答案

查看official documentation,如果您正在运行Elasticsearch 1.x集群,则有两个选择:

  • 首先升级到Elasticsearch 2.4.x,重新索引旧索引,然后再升级到5.x。
  • 创建一个新的5.x集群,并使用reindex-from-remote直接从1.x集群导入索引。

  • Reindex in place

    The easiest way to reindex old (1.x) indices in place is to use the Elasticsearch Migration Plugin. You will need to upgrade to Elasticsearch 2.3.x or 2.4.x first.

    The reindex utility provided in the migration plugin does the following:

    • Creates a new index with the Elasticsearch version appended to the old index name (e.g. my_index-2.4.1), copying the mappings and settings from the old index. Refresh is disabled on the new index and the number of replicas is set to 0 for efficient reindexing.
    • Sets the old index to read only to ensure that no data is written to the old index.
    • Reindexes all documents from the old index to the new index.
    • Resets the refresh_interval and number_of_replicas to the values used in the old index, and waits for the index to become green.
    • Adds any aliases that existed on the old index to the new index.
    • Deletes the old index.
    • Adds an alias to the new index with the old index name, e.g. alias my_index points to index my_index-2.4.1.

    At the end of this process, you will have a new 2.x index which can be used by an Elasticsearch 5.x cluster.



    Upgrading with reindex-from-remote

    If you are running a 1.x cluster and would like to migrate directly to 5.x without first migrating to 2.x, you can do so using reindex-from-remote.

    You will need to set up a 5.x cluster alongside your existing 1.x cluster. The 5.x cluster needs to have access to the REST API of the 1.x cluster.

    For each 1.x index that you want to transfer to the 5.x cluster, you will need to:

    • Create a new index in 5.x with the appropriate mappings and settings.
    • Set the refresh_interval to -1 and set number_of_replicas to 0 for faster reindexing.
    • Use reindex-from-remote to pull documents from the 1.x index into the new 5.x index. If you run the reindex job in the background (with wait_for_completion set to false), the reindex request will return a task_id which can be used to monitor progress of the reindex job in the task API: GET _tasks/TASK_ID.
    • Once reindex has completed, set the refresh_interval and number_of_replicas to the desired values (the defaults are 30s and 1 respectively).
    • Once the new index has finished replication, you can delete the old index.

    关于elasticsearch - elasticsearch从1.7.x升级到5.2.x,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42551009/

    相关文章:

    elasticsearch - 如何有效地只获取文档的一个字段进行 Elasticsearch

    elasticsearch - 如何按特定字段过滤 Elasticsearch 词或短语建议器?

    ruby-on-rails - SearchKick(Elastic Search) 重新索引特定记录

    elasticsearch - _ttl更新不适用于doc选项

    spring - 为什么在使用spring-data-elasticsearch时将HEAD请求发送到我的索引

    elasticsearch - 查询elasticsearch返回所有文档

    Elasticsearch的Common Terms Query, use and compatibility with query types

    php - Elasticsearch按查询删除多个术语

    php - Elasticsearch 数据导入时间表

    docker - 如何在 Docker compose 3 中设置 path.repo?