ELK之elasticdump迁移es数据
参考:https://www.cnblogs.com/resn/p/9082663.html
elasticsearch部分查询语句
获取集群节点列表
1 | curl "172.16.30.55:9200/_cat/nodes?v" |
列出所有索引
1 | curl "172.16.30.55:9200/_cat/indices?v" |
如果节点安装了search guard认证使用以下命令
1 | curl "https://admin:admin@172.16.30.55:9200/_cat/indices?v" - k |
-k取消证书验证而使用用户名和密码验证
安装elasticdump
1 2 3 4 5 6 7 8 9 10 11 12 13 | wget https: / / nodejs.org / dist / v8. 11.2 / node - v8. 11.2 - linux - x64.tar.xz tar xf node - v8. 11.2 - linux - x64.tar.xz mv node - v8. 11.2 - linux - x64 / usr / local ln - s / usr / local / node - v8. 11.2 - linux - x64 / bin / npm / usr / local / bin / npm ln - s / usr / local / node - v8. 11.2 - linux - x64 / bin / node / usr / local / bin / node npm init - f npm install elasticdump |
2023-12-28安装时报错
1 | error code EUNSUPPORTEDPROTOCOL |
升级版本例如14版本
修改文件增加以下内容/etc/profile
注意: node_mpdules路径为执行npm install elasticdupm命令对应的路径
1 2 3 | export NODE_HOME = / usr / local / node - v8. 11.2 - linux - x64 export PATH = $PATH:$NODE_HOME / bin : / opt / node_modules / elasticdump / bin export NODE_PATH = $NODE_HOME / lib / node_modules |
设置生效
1 | source / etc / profile |
数据迁移
数据通过网络进行迁移 从主机172.16.30.55迁移至172.16.30.56
1 2 3 4 5 6 7 8 9 | #拷贝映射 elasticdump \ - - input = http: / / 172.16 . 30.55 : 9200 / nginx - prod - log - 2019.02 \ - - output = http: / / 172.16 . 30.55 : 9200 / nginx - prod - log - 2019.02 \ - - type = mapping #拷贝数据 elasticdump \ - - input = http: / / 172.16 . 30.55 : 9200 / nginx - prod - log - 2019.02 \ - - output = http: / / 172.16 . 30.56 : 9200 / nginx - prod - log - 2019.02 \ - - type = data |
如果网络不好或者没有网络还可以先备份到文件
1 2 3 4 5 6 7 8 9 10 11 | #备份映射 elasticdump \ - - input = http: / / 172.16 . 30.55 : 9200 / nginx - prod - log - 2019.02 \ - - output = / tmp / nginx - prod - log_mapping.json \ - - type = mapping #备份数据 elasticdump \ - - input = http: / / 172.16 . 30.55 : 9200 / nginx - prod - log - 2019.02 \ - - output = / tmp / nginx - prod - log_data.json \ - - type = data |
通过备份文件恢复数据
1 2 3 4 5 6 7 8 9 | #恢复映射 elasticdump \ - - input = / tmp / nginx - prod - log_mapping.json \ - - output = http: / / 172.16 . 30.55 : 9200 / \ #恢复数据 elasticdump \ - - input = / tmp / nginx - prod - log_data.json \ - - output = http: / / 172.16 . 30.55 : 9200 / \ |
加密的数据迁移 当客户端使用search guard进行加密时候数据迁移命令格式如下
1 2 3 | #前面加参数,后面https加入用户名和密码即可 NODE_TLS_REJECT_UNAUTHORIZED = 0 elasticdump - - input = http: / / 172.16 . 90.11 : 9200 / try_on_2019. 03 - - output = https: / / admin:admin@ 172.16 . 30.11 : 9200 / try_on_2019. 03 - - type = mapping NODE_TLS_REJECT_UNAUTHORIZED = 0 elasticdump - - input = http: / / 172.16 . 90.11 : 9200 / try_on_2019. 03 - - output = https: / / admin:admin@ 172.16 . 30.11 : 9200 / try_on_2019. 03 - - type = data |
PS:同理如果是output端是search guard加密也是在前面加参数然后把http改成https后面在加用户名和密码认证
从备份好的json文件恢复至加密的elasticsearch命令格式如下
1 2 | NODE_TLS_REJECT_UNAUTHORIZED = 0 elasticdump - - input = mapping20190610 / on_the_ark_2019. 02_mapping .json - - output = https: / / root:password@ 172.16 . 30.11 : 9200 NODE_TLS_REJECT_UNAUTHORIZED = 0 elasticdump - - input = data20190610 / 96_stock_data .json - - output = https: / / root:password@ 172.16 . 30.11 : 9200 / |
PS:输入不需要加密认证,输出不需要加--type参数
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!