博客详情

elasticsearch中索引数据的导出和导入 (原创)

作者: 朝如青丝暮成雪
发布时间:2020-05-21 23:17:25  文章分类:elasticsearch   阅读(5898)  评论(0)


如题,我们需要将服务器A上的ES索引数据全部备份导出,再导入到服务器B中。

npm install -g elasticdump 


1、服务器A上查看都有哪些索引

curl  -X GET  http://localhost:9200/_cat/indices ,例如

my_index1

my_index1

my_index3

说明有ES库中有3个索引对象


2、服务器A上依次导出3个索引对象(mapping和data)

#导出3个索引

elasticdump --input=http://localhost:9200/my_index1  --output=/root/my_index1_m.json  --type=mapping

elasticdump --input=http://localhost:9200/my_index1  --output=/root/my_index1_d.json  --type=data


elasticdump --input=http://localhost:9200/my_index2  --output=/root/my_index2_m.json  --type=mapping

elasticdump --input=http://localhost:9200/my_index2  --output=/root/my_index2_d.json  --type=data


elasticdump --input=http://localhost:9200/my_index3  --output=/root/my_index3_m.json  --type=mapping

elasticdump --input=http://localhost:9200/my_index3  --output=/root/my_index3_d.json  --type=data



3、将服务器A的导出文件(json) 传到服务器B上

scp  my_index1_m.json  serverB:/root/

scp  my_index1_d.json  serverB:/root/

scp  my_index2_m.json  serverB:/root/

scp  my_index2_d.json  serverB:/root/

scp  my_index3_m.json  serverB:/root/

scp  my_index4_d.json  serverB:/root/


(

删除服务器B上的索引

curl -X DELETE http://localhost:9200/my_index1
curl -X DELETE http://localhost:9200/my_index2
curl -X DELETE http://localhost:9200/my_index3


)


#导入3个索引

elasticdump --input=http://localhost:9200/my_index1 --output=/root/my_index1_m.json --type=mapping
elasticdump --input=http://localhost:9200/my_index1 --output=/root/my_index1_d.json --type=data


elasticdump --input=http://localhost:9200/my_index2 --output=/root/my_index2_m.json --type=mapping
elasticdump --input=http://localhost:9200/my_index2 --output=/root/my_index2_d.json --type=data


elasticdump --input=http://localhost:9200/my_index3 --output=/root/my_index3_m.json --type=mapping
elasticdump --input=http://localhost:9200/my_index4 --output=/root/my_index3_d.json --type=data

 







关键字:  elasticsearch  elasticdump
评论信息
暂无评论
发表评论

亲,您还没有登陆,暂不能评论哦! 去 登陆 | 注册

博主信息
   
数据加载中,请稍候...
文章分类
   
数据加载中,请稍候...
阅读排行
 
数据加载中,请稍候...
评论排行
 
数据加载中,请稍候...

Copyright © 叮叮声的奶酪 版权所有
备案号:鄂ICP备17018671号-1

鄂公网安备 42011102000739号