ES升级和数据迁移

一、背景
 公司项目升级,ES版本由原来的2.x升级到5.x,同时会涉及到海量数据(几十个T)的迁移。

二、方案
 1、高版本ES直接使用低版本ES的持久化数据文件和日志文件
  编辑elasticsearch.yml配置文件使path.data和path.logs的路径指向低版本对应的路径。
  结果:未能识别出数据,应该是存在版本兼容性问题

 2、利用第三方工具将低版本的索引数据导入到高版本中
  选择的工具是elasticsearch-migration,相关介绍:elasticsearch-migration
  使用shell脚本做迁移和历史记录,脚本内容如下:

#!/bin/sh
dir="/data/esmigrate/bin/linux64" # elasticsearch-migration解压后esm命令所在目录
cd ${dir}
rm -f es_indices.txt
curl -s 'http://localhost:9201/_cat/indices?v' | grep -e index1_* -e index2_* | awk '{print $3}' > es_indices.txt # index1_* 和 index2_* 是模糊匹配的要迁移的索引
for i in `cat es_indices.txt`
do
	if [ ! -e "es_md_indices.txt" ]
	then
		touch es_md_indices.txt
	fi
	tmp=`grep -o $i es_md_indices.txt | wc -l`
	if [ $tmp -eq 0 ]
	then
		./esm -s http://localhost:9201 -d http://localhost:9202 -x $i -w=5 -b=10 -c 10000 --force
		echo $i >> es_md_indices.txt
	fi
done

  好处是在迁移过程中出错时,可以通过修改 es_indices.txt 和 es_md_indices.txt 进行控制。

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值