elasticdump迁移ES数据详解

简介: elasticdump迁移ES数据详解

elasticdump 简介


elasticdump是一个能够将es的数据快速导入、导出、迁移的工具。


1.elasticdump导入ES数据到本地json文件


elasticdump --input=http://elastic:elastic@ip:9200/a_ems_xqd_11/xqd  --output=D:/xqd.json


2、将本地数据导入es中


elasticdump  --input=D:/ES/date/demo.json --output=http://localhost:9200/demo1


如果报错信息如下:

Wed, 07 Jun 2023 01:39:16 GMT | dump ended with error (get phase) => UNAUTHORIZED: {“error”:{“root_cause”:[{“type”:“security_exception”,“reason”:“missing authentication token for REST request [/]”,“header”:{“WWW-Authenticate”:"Basic realm=“security” charset=“UTF-8"”}}],“type”:“security_exception”,“reason”:“missing authentication token for REST request [/]”,“header”:{“WWW-Authenticate”:"Basic realm=“security” charset=“UTF-8"”}},“status”:401}

那么表示无权限访问或未授权访问目标Elasticsearch集群,需要加上用户名和密码

命令如下:


elasticdump  --input=D:/ryxx.json --output=http://username:password@IP:9200/my_index  --type=data


有些人用


elasticdump  --input=D:/ryxx.json --output=http://IP:9200/my_index  --username=username --password=password --type=data

这个是不对的,这个会报错


3、将es导入另一个es


elasticdump --input=http://ip:9200/demo --output=http://127.0.0.1:9200/demo

4 .其他参数


elasticdump \
  --input=http://elastic:password@host:port/index_aaa \
  --output=http://elastic:password@host:port/index_bbb \
  --type=data --limit 1000 --support-big-int

通过指定--limit 1000,设置每批次同步文档数量。

注:通过指定--support-big-int参数,解决long类型字段丢失精度问题。

根据条件进行查询 到的数据进行迁移,

现在kibana中查询好,然后复制查询语句,将语句进行压缩转义然后执行即可

查询语句json要先进行压缩转义

https://www.bejson.com/


使用–searchBody

elasticdump --input=http://elastic:elastic@ip:9200/a_ems_xqd_11/xqd  --output=D:/xqd.json --searchBody {\"query\":{\"bool\":{\"must\":[{\"range\":{\"JD\":{\"from\":116.388474,\"to\":116.67818,\"include_lower\":true,\"include_upper\":true,\"boost\":1.0}}},{\"range\":{\"WD\":{\"from\":39.621549,\"to\":39.839061,\"include_lower\":true,\"include_upper\":true,\"boost\":1.0}}}],\"must_not\":[{\"term\":{\"JLZT\":{\"value\":\"0\",\"boost\":1.0}}}],\"disable_coord\":false,\"adjust_pure_negative\":true,\"boost\":1.0}}} --limit 10000
elasticdump --input=http://elastic:elastic@ip:9200/a_ems_xtzd/xtzd  --output=D:/xtzd.json --searchBody {\"query\":{\"bool\":{\"must\":[{\"term\":{\"ZDLX\":{\"value\":\"ZQXX_ZQLX\",\"boost\":1.0}}},{\"prefix\":{\"BZXX\":{\"value\":\"A01\"}}}]}}}


使用–searchBody 向本机ES导数据


elasticdump --input=http://elastic:elastic@ip:9200/a_ems_xqd_11/xqd  --output=http://localhost:9200/a_ems_xqd_11/xqd --searchBody {\"query\":{\"bool\":{\"must\":[{\"range\":{\"JD\":{\"from\":116.388474,\"to\":116.67818,\"include_lower\":true,\"include_upper\":true,\"boost\":1.0}}},{\"range\":{\"WD\":{\"from\":39.621549,\"to\":39.839061,\"include_lower\":true,\"include_upper\":true,\"boost\":1.0}}}],\"must_not\":[{\"term\":{\"JLZT\":{\"value\":\"0\",\"boost\":1.0}}}],\"disable_coord\":false,\"adjust_pure_negative\":true,\"boost\":1.0}}} --limit 10000


使用–type=analyzer导出分析器


elasticdump --input=http://elastic:elastic@ip:9200/a_ems_xqd_11/xqd  --output=D:/xqd.json --type=analyzer


结语


🔥一个人可以掌握知识,但只有与他人交流才能形成智慧。

🔥One person can acquire knowledge, but wisdom is formed only in the exchange with others.

🏆 我坚信人与人之间的差距是表面上是财富的差距,本质上是大脑中认知的差距,

相关文章
|
SQL JSON Java
【Elasticsearch专栏 10】深入探索:Elasticsearch如何进行数据导入和导出
在Elasticsearch中,数据导入常通过Bulk API、Logstash或Java客户端进行,支持JSON、CSV等格式。导出则可通过SQL查询、Scroll API或第三方工具如elasticdump实现,将数据以JSON、CSV等格式导出。这些方法确保了数据的高效、安全导入与导出。
2484 5
|
弹性计算 JavaScript Linux
ElasticSearch备份与恢复-elasticdump工具
ElasticSearch备份与恢复-elasticdump工具
|
关系型数据库 MySQL 数据库连接
PHPStudy(小皮)V8.1 中使用cmd进入MySQL命令行模式
1、找到phpstudy_pro中的mysql可执行文件所在的位置(安装位置) 把这个路径进行复制:D:\phpstudy_pro\Extensions\MySQL5.7.26\bin image.png
2633 0
|
安全 应用服务中间件 Apache
目标URL存在http host头攻击漏洞
目标URL存在http host头攻击漏洞
2008 0
目标URL存在http host头攻击漏洞
|
6月前
|
人工智能 自然语言处理 安全
Claude Code 全攻略:命令大全 + 实战工作流(建议收藏)
本文介绍了Claude Code终端AI助手的使用指南,主要内容包括:1)常用命令如版本查看、项目启动和更新;2)三种工作模式切换及界面说明;3)核心功能指令速查表,包含初始化、压缩对话、清除历史等操作;4)详细解析了/init、/help、/clear、/compact、/memory等关键命令的使用场景和语法。文章通过丰富的界面截图和场景示例,帮助开发者快速掌握如何通过命令行和交互界面高效使用Claude Code进行项目开发,特别强调了CLAUDE.md文件作为项目知识库的核心作用。
51873 73
Claude Code 全攻略:命令大全 + 实战工作流(建议收藏)
|
10月前
|
NoSQL IDE MongoDB
Studio 3T 2025.22 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.22 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
306 0
Studio 3T 2025.22 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
|
云安全 人工智能 安全
大模型+安全,阿里云发布AI云盾系列产品!
阿里云正式发布AI云盾(Cloud Shield for AI)系列安全产品,包括AI安全护栏、升级云安全中心、WAAP和云防火墙。该系列提供模型输入输出安全、AI-BOM、AI-SPM等能力,构建三层模型安全防御体系,涵盖AI基础设施、大模型及应用安全。其中,AI安全护栏保障生成式AI合规性,实时检测威胁并维护模型健康,支持多模态内容交叉检测的All In One API调用模式。此外,AI-BOM与AI-SPM助力客户持续监控AI资产及安全状态。
1817 3
大模型+安全,阿里云发布AI云盾系列产品!
|
11月前
|
机器学习/深度学习 人工智能 前端开发
终端里的 AI 编程助手:OpenCode 使用指南
OpenCode 是开源的终端 AI 编码助手,支持 Claude、GPT-4 等模型,可在命令行完成代码编写、Bug 修复、项目重构。提供原生终端界面和上下文感知能力,适合全栈开发者和终端用户使用。
61510 11

热门文章

最新文章