Elasticsearch 数据迁移

Elasticsearch 数据迁移

  • 使用elaticsearch-dump 方式进行迁移
# 安装nodejs
cd /opt
wget https://npm.taobao.org/mirrors/node/v10.15.3/node-v10.15.3-linux-x64.tar.gz
tar xf node-v10.15.3-linux-x64.tar.gz
mv  node-v10.15.3-linux-x64 node 
echo "export NODE_HOME=/opt/node" >> /etc/profile
echo "export PATH=\${NODE_HOME}/bin:$PATH" >> /etc/profile
source /etc/profile

# 安装elasticdump 
npm install elasticdump -g     #全局安装
  • 记录待迁移elasticsearch 索引数据内容和数据总量,以便迁移后核对
curl http://ip:9200/_cat/indices
  • 直接从源es到迁移到新的es,源es --> 新es
# 备份 mapping
elasticdump --input="http://localhost:9200/MyIndex" --output="http://1.2.3.4:9200/MyIndex" --type=mapping
# 备份数据
elasticdump --input="http://localhost:9200/MyIndex" --output="http://1.2.3.4:9200/MyIndex" --type=data

posted @ 2023-07-07 19:50  lixinliang  阅读(73)  评论(0编辑  收藏  举报