之前有博客介绍过通过 Reindex 的方法将 Elasticsearch 的数据迁移到 Easysearch 集群,今天再介绍一个方法,通过 极限网关(INFINI Gateway) 来进行数据迁移。
测试环境
软件 | 版本 |
---|---|
Easysearch | 1.12.0 |
Elasticsearch | 7.17.29 |
INFINI Gateway | 1.29.2 |
迁移步骤
- 选定要迁移的索引
- 在目标集群建立索引的 mapping 和 setting
- 准备 INFINI Gateway 迁移配置
- 运行 INFINI Gateway 进行数据迁移
迁移实战
- 选定要迁移的索引
在 Elasticsearch 集群中选择目标索引:infinilabs 和 test1,没错,我们一次可以迁移多个。
- 在 Easysearch 集群使用源索引的 setting 和 mapping 建立目标索引。(略)
- INFINI Gateway 迁移配置准备
去 github 下载配置,修改下面的连接集群的部分
1 env:2 LR_GATEWAY_API_HOST: 127.0.0.1:29003 SRC_ELASTICSEARCH_ENDPOINT: http://127.0.0.1:92004 DST_ELASTICSEARCH_ENDPOINT: http://127.0.0.1:92015 path.data: data6 path.logs: log7 progress_bar.enabled: true8 configs.auto_reload: true910 api:11 enabled: true12 network:13 binding: $[[env.LR_GATEWAY_API_HOST]]1415 elasticsearch:16 - name: source17 enabled: true18 endpoint: $[[env.SRC_ELASTICSEARCH_ENDPOINT]]19 basic_auth:20 username: elastic21 password: goodgoodstudy2223 - name: target24 enabled: true25 endpoint: $[[env.DST_ELASTICSEARCH_ENDPOINT]]26 basic_auth:27 username: admin28 password: 14da41c79ad2d744b90c
pipeline 部分修改要迁移的索引名称,我们迁移 infinilabs 和 test1 两个索引。
31 pipeline:32 - name: source_scroll33 auto_start: true34 keep_running: false35 processor:36 - es_scroll:37 slice_size: 138 batch_size: 500039 indices: "infinilabs,test1"40 elasticsearch: source41 output_queue: source_index_dump42 partition_size: 143 scroll_time: "5m"
- 迁移数据
./gateway-mac-arm64#如果你保存的配置文件名称不叫 gateway.yml,则需要加参数 -config 文件名
数据导入完成后,网关 ctrl+c 退出。
至此,数据迁移就完成了。下一篇我们来介绍 INFINI Gateway 的数据比对功能。
关于极限网关(INFINI Gateway)
INFINI Gateway 是一个开源的面向搜索场景的高性能数据网关,所有请求都经过网关处理后再转发到后端的搜索业务集群。基于 INFINI Gateway,可以实现索引级别的限速限流、常见查询的缓存加速、查询请求的审计、查询结果的动态修改等等。
官网文档:https://docs.infinilabs.com/gateway
开源地址:https://github.com/infinilabs/gateway