Elasticsearch-dump 迁移数据

elasticsearch-dump可以将ES中的某个索引数据迁移至其他的ES中,或者将ES数据整体迁移,我这里的场景是将生产的ES索引数据迁移至开发环境的ES中

1、elasticsearch-dump迁移

Tools for moving and saving indicies. 从来移动和保存索引的工具。

GITHUB项目地址: https://github.com/taskrabbit/elasticsearch-dump

1.1 主要参数说明
--input: 源地址,可为 ES 集群 URL、文件或 stdin,可指定索引,格式为 {protocol}://{host}:{port}/{index}
--input-index: 源 ES 集群中的索引
--output: 目标地址,可为 ES 集群地址 URL、文件或 stdout,可指定索引,格式为:{protocol}://{host}:{port}/{index}
--output-index: 目标 ES 集群的索引
--type: 迁移类型,默认为 data,表明只迁移数据,可选 settings, analyzer, data, mapping, alias
1.2 安装elasticsearch-dump
1.2 elasticsearch-dump安装
1) yum install epel-release
2) yum install nodejs
3) yum install npm
4) npm install elasticdump
5) cd node_modules/elasticdump/bin 

安装后查看目录:

[elasticdump]# pwd
/root/node_modules/elasticdump
[elasticdump]# ls -al
total 72
drwxr-xr-x   6 root root   165 Oct 13 11:41 .
drwxr-xr-x 130 root root  4096 Oct 13 11:41 ..
drwxr-xr-x   2 root root    49 Oct 13 11:41 bin
-rw-r--r--   1 root root   322 Oct 13 11:41 Dockerfile_local
-rw-r--r--   1 root root  2769 Oct 13 11:41 elasticdump.js
drwxr-xr-x   4 root root   301 Oct 13 11:41 lib
-rw-r--r--   1 root root 11356 Oct 13 11:41 LICENSE.txt
-rw-r--r--   1 root root  1669 Oct 13 11:41 package.json
-rw-r--r--   1 root root 40447 Oct 13 11:41 README.md
drwxr-xr-x   2 root root    22 Oct 13 11:41 templates
drwxr-xr-x   2 root root    26 Oct 13 11:41 transforms
1.3 elasticsearch-dump使用
1.3.1 迁移单个索引

以下操作通过 elasticdump 命令将集群172.18.1.164中的 my_index索引迁移至集群172.16.9.13。
第一条命令先将索引的 settings 先迁移,如果直接迁移 mapping 或者 data 将失去原有集群中索引的配置信息如分片数量和副本数量等,当然也可以直接在目标集群中将索引创建完毕后再同步 mapping 与 data。

拷贝数据
./elasticdump \
  --input=http://172.18.1.164:9200/my_index \
  --output=http://172.16.9.13:9200/my_index \
  --type=settings
拷贝analyzer
./elasticdump \
  --input=http://172.18.1.164:9200/my_index \
  --output=http://172.16.9.13:9200/my_index \
  --type=analyzer
拷贝映射
./elasticdump \
  --input=http://172.18.1.164:9200/my_index \
  --output=http://172.16.9.13:9200/my_index \
  --type=mapping
拷贝数据
./elasticdump \
  --input=http://172.18.1.164:9200/my_index \
  --output=http://172.16.9.13:9200/my_index \
  --type=data

在这里插入图片描述

1.3.2 迁移所有索引
./elasticdump \
  --input=http://172.18.1.164:9200 \
  --output=http://172.16.9.13:9200
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值