Posted on:
Last modified:
最近需要把一个 ES 5.5 的集群迁移到 K8S 上,因为目标环境中只有 ES 7 集群,所以在迁移过程中 还需要升级下索引的版本。
开始看到了一个 reindex 的 API,想着直接从老集群 reindex 过去就好了,结果发现不行。直接 reindex 会丢掉类型信息。
首先尝试了一个搜到的工具:ElasticDump
, 然而速度太慢了。后来发现 ES 有原生的 snapshot
API,只需要使用这个 API 备份好,然后导入新的集群即可,而且再这个过程中还可以升级版本,简直
完美。具体操作如下:
以上操作在官方文档「Snapshot and Restore」中均有详细描述,这里就不赘述了。
因为 7.2+ 只支持导入 6.0+ 的 snapshot 和索引,所以其中的关键一步是在 6.8 中 reindex 索引, 否则会出现不兼容情况.
因为我的集群中没有安装任何插件,所以插件的兼容性和升级也不用考虑。
虽然在 7.0 中已经移除了对 mapping type 的支持,但是以前创建的索引还是可以用的,所以
查看集群的恢复状态:
GET _cat/recovery?v&pretty
查看 snapshot 的状态
GET /_snapshot/my_backup/snapshot_1
查看 snapshot 详情
GET /_snapshot/my_backup/snapshot_1/_status
© 2016-2022 Yifei Kong. Powered by ynotes
All contents are under the CC-BY-NC-SA license, if not otherwise specified.
Opinions expressed here are solely my own and do not express the views or opinions of my employer.