ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

elasticsearch7.15.1迁移索引记录

2021-11-12 17:04:48  阅读:184  来源: 互联网

标签:http 9200 -- com 索引 elasticsearch7.15 迁移 elasticdump es


背景

因业务需要将旧es单机所有索引及数据迁移至新es集群,网上调研了一番决定使用elasticdump

官方主页:https://github.com/elasticsearch-dump/elasticsearch-dump

过程

安装

使用nodejs开发的,需要先安装node

wget https://repo.huaweicloud.com/nodejs/latest-v14.x/node-v14.17.5-linux-x64.tar.gz
tar zxvf node-v14.17.5-linux-x64.tar.gz -c /usr/local/node
cat <<'EOF'> /etc/profile.d/node.sh
export NODE_HOME=/usr/local/node
export PATH=$NODE_HOME/bin:$PATH
EOF
source /etc/profile

注意不要使用cnpm安装elasticdump,操作了几次都安装失败,改为用npm

npm install elasticdump -g
ln -fs /usr/local/node/bin/* /usr/bin
elasticdump

例子

官方给的迁移例子:

# Copy an index from production to staging with analyzer and mapping:
elasticdump \
  --input=http://production.es.com:9200/my_index \
  --output=http://staging.es.com:9200/my_index \
  --type=analyzer
elasticdump \
  --input=http://production.es.com:9200/my_index \
  --output=http://staging.es.com:9200/my_index \
  --type=mapping
elasticdump \
  --input=http://production.es.com:9200/my_index \
  --output=http://staging.es.com:9200/my_index \
  --type=data

如果es开启了认证,则是这样:

--input=http://name:password@production.es.com:9200/my_index

其他还有挺多功能的,比如如果你网络不好,可以先备份到文件再恢复,其余功能请自行挖掘。

开工

首先获取到es的所有索引

curl -u elastic:'xx'  'http://localhost:9200/_cat/indices?v'

如有个索引叫yy,则使用如下方式迁移:
建议用screen或tmux进行,通常迁移需要的时间较长。

elasticdump \
  --input=http://elastic:xx@192.168.69.33:9200/yy \
  --output=http://elastic:xx@192.168.69.85:9200/yy \
  --type=analyzer
elasticdump \
  --input=http://elastic:xx@192.168.69.33:9200/yy \
  --output=http://elastic:xx@192.168.69.85:9200/yy \
  --type=mapping
elasticdump \
  --input=http://elastic:xx@192.168.69.33:9200/yy \
  --output=http://elastic:xx@192.168.69.85:9200/yy \
  --type=data

迁移过程:
image

迁移完成:
image

标签:http,9200,--,com,索引,elasticsearch7.15,迁移,elasticdump,es
来源: https://www.cnblogs.com/fsckzy/p/15545465.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有