首页 > 其他 > 详细

利用elasticsearch-dump实现es索引数据迁移附脚本

时间:2019-09-30 12:15:33      阅读:248      评论:0      收藏:0      [点我收藏+]

1、安装环境

CentOS Linux release 7.5.1804 (Core)
  • 1

2、安装nodejs

yum install -y nodejs
  • 1

3、验证nodejs

[root@localhost yum.repos.d]# node -v
v8.12.0
[root@localhost yum.repos.d]# npm -v
6.4.1
  • 1
  • 2
  • 3
  • 4

4、安装elasticsearch-dump

npm install elasticdump
  • 1

5、验证安装

进入elasticdump/bin目录下

cd node_modules/elasticdump/bin/
  • 1

执行

 ./elasticdump
  • 1

出现

Fri, 19 Oct 2018 07:03:15 GMT | Error Emitted => {"errors":["`input` is a required input","`output` is a required input"]}
  • 1

报错是因为没有输入参数

6、使用dump迁移索引

#拷贝索引

elasticdump 
	--input=http://production.es.com:9200/my_index 
	--output=http://staging.es.com:9200/my_index 
	--type=mapping
  • 1
  • 2
  • 3
  • 4

#拷贝数据

elasticdump 
	--input=http://production.es.com:9200/my_index 
	--output=http://staging.es.com:9200/my_index 
	--type=data
  • 1
  • 2
  • 3
  • 4

#拷贝所有索引

elasticdump  
	--input=http://production.es.com:9200/ 
	--output=http://staging.es.com:9200/ 
	--all=true  
  • 1
  • 2
  • 3
  • 4

7、迁移实战

为了方便操作写了一个脚本,仅供参考。

#!/bin/bash
echo -n "源ES地址: "
read old
echo -n "目标ES地址: "
read new
echo -n "源索引名: "
read old_index
echo -n "目标索引名: "
read new_index
cd /root/node_modules/elasticdump/bin/
 ./elasticdump --input=$old/$old_index  --output=$new/$new_index  --type=mapping &>> /root/dump.log
 ./elasticdump --input=$old/$old_index  --output=$new/$new_index  --type=data &>> /root/dump.log

利用elasticsearch-dump实现es索引数据迁移附脚本

原文:https://www.cnblogs.com/agang-php/p/11611769.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!