1、elasticdump 用途介绍
elasticdump 是一个在 Github 开源的 Elasticsearch 的数据迁移工具,项目 Github 地址:[传送门](Github 地址:https://github.com/elasticsearch-dump/elasticsearch-dump)
elasticdump 支持跨版本导出和导入数据,用法简单,安装方便。
elasti开发者用了下面一张图来形象的描述了 elasticdump 的作用

elasticdump 具有以下特点
安装方便、使用简单 免费 支持导出为数据文件,亦支持从文件导入到索引 可以直接从 source service 导入到 target service
2、安装 node
使用 node 安装 elasticdump 非常方便。
node 官网:https://nodejs.org/en/
3、安装 elasticdump
3.1 基于本地安装
本地安装:使用时较为麻烦,不推荐
npm install elasticdump
复制
Mac 系统下默认安装位置为:/Users/<user_name>/node_modules/elasticdump
启动
./bin/elasticdump
复制
3.2 基于全局安装(推荐)
sudo npm install elasticdump -g
复制
4、准备数据源服务和目标服务
博主准备了以下两个服务,将在本文第 6 小节演示数据的迁移
具体信息如下:
源数据服务:source | 目标数据服务:data | |
---|---|---|
版本号 | 7.13 | 8.5 |
服务地址 | http://localhost:9213/ | http://localhost:9200/ |
索引名称 | test_index | test_index |
5、使用方法
5.1 一行代码看懂用法
elasticdump --input <源数据> --output <目标数据> --type=<数据类型>
复制
5.2 数据源或者目标数据可以是文件或者 URL
源数据服务或者目标数据服务配置方法如下
Elasticsearch:
format: {protocol}://{host}:{port}/{index} example: http://127.0.0.1:9200/my_index
File:
format: {FilePath} example: Users/evantahler/Desktop/dump.json
5.3 重要选项
input:源数据的位置,此项为必须项 output:目标数据的保存位置:此项为必须项 type:默认为 data
,
支持以下可选项:
settings analyzer data mapping policy alias template component_template, index_template
6、案例
6.1 以数据文件形式迁移
以文件方式导入导出,如果数据量很大,会占用很大的磁盘空间
6.1.1 导出源数据的 mapping 和 data
1:导出源数据索引的 mapping
在导出数据的时候,需要指定导出的数据类型
elasticdump --input http://localhost:9213/test_index --output /Users/wu/Desktop/test_index_mapping.json --type=mapping
复制
2:导出指定索引的 data 为文件
elasticdump --input http://localhost:9213/test_index --output /Users/wu/Desktop/test_index.json --type=data
复制
6.1.2 将导出的数据文件导入至目标索引
1:创建目标索引的空索引
// curl -XPUT http:localhost:9200/test_index
PUT test_index复制
2:导入 mapping 至目标索引
elasticdump --input /Users/wu/Desktop/test_index_mapping.json --output http://localhost:9200/ --type=mapping
复制
3:导入 data 至目标索引
$ elasticdump --input /Users/wu/Desktop/test_index.json --output http://localhost:9200/ --type=data
复制
6.2 从数据源直接导入到目标集群
6.2.1 迁移 mapping
elasticdump --input http://localhost:9213/test_index --output http://localhost:9200/ --type=mapping
复制
6.2.2 迁移 data
elasticdump --input http://localhost:9213/test_index --output http://localhost:9200/ --type=data
复制
长按加关注,更多干货内容不错过


无论您漂泊到何处
这里都是您的灵魂树洞
长按识别二维码关注我们


文章转载自Elasticsearch之家,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
云和恩墨钟浪峰:安全生产系列之SQL优化安全操作
墨天轮编辑部
238次阅读
2025-03-31 11:08:20
案例-索引对于并发Insert性能优化测试
布衣
92次阅读
2025-04-09 22:47:23
Oracle数据库常用脚本(八)
hongg
57次阅读
2025-04-02 09:09:23
PolarDB PostgreSQL版索引预读原理介绍
PolarDB
43次阅读
2025-03-27 10:00:42
PostgreSQL性能调优
飞象数据
41次阅读
2025-04-01 12:26:50
TiDB 可观测性解读系列:索引与算子执行性能优化实践
TiDB Club
39次阅读
2025-04-01 18:30:31
人大、腾讯数据库联合攻坚交答卷:7项顶会论文突破,成果落地TDSQL产线
腾讯云数据库
39次阅读
2025-03-31 10:00:30
《深度剖析SQL之WHERE子句:数据过滤的艺术》
程序员阿伟
39次阅读
2025-03-28 19:13:31
使用 MySQLShell 9.2.0 进行数据增量导出
阮胜昌
36次阅读
2025-04-01 17:39:38
数据库进阶系列之一:漫谈数据库索引
淡定
35次阅读
2025-03-31 19:38:04