如题,我们需要将服务器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
Copyright © 叮叮声的奶酪 版权所有
备案号:鄂ICP备17018671号-1