迁移工具:

elasticsearch-dump

 

前提:

阿里云elasticsearch开启“自动创建索引

 

一、安装elasticdump

  1. 安装node.js。

    1. 下载安装包。

       
      wget https://nodejs.org/dist/v16.18.0/node-v16.18.0-linux-x64.tar.xz
    2. 解压。

       
      tar -xf node-v16.18.0-linux-x64.tar.xz
    3. 设置环境变量。

      • 临时生效

         
        export PATH=$PATH:/root/node-v16.18.0-linux-x64/bin/
      • 永久生效

         
        vim ~/.bash_profile
        export PATH=$PATH:/root/node-v16.18.0-linux-x64/bin/
        source ~/.bash_profile

安装elasticsearch-dump。

 
npm install elasticdump -g
查看安装目录
npm root -g
ln -s /usr/local/node/lib/node_modules/elasticdump/bin/elasticdump /usr/local/bin

 

二、迁移指定索引
迁移指定索引的settings

elasticdump --input=http://"<UserName>:<YourPassword>"@<YourEsHost>/<YourEsIndex> --output=http://"<OtherName>:<OtherPassword>"@<OtherEsHost>/<OtherEsIndex> --type=settings --limit 10000

迁移指定索引的mapping


elasticdump --input=http://"<UserName>:<YourPassword>"@<YourEsHost>/<YourEsIndex> --output=http://"<OtherName>:<OtherPassword>"@<OtherEsHost>/<OtherEsIndex> --type=mapping --limit 10000

迁移指定索引的data


elasticdump --input=http://"<UserName>:<YourPassword>"@<YourEsHost>/<YourEsIndex> --output=http://"<OtherName>:<OtherPassword>"@<OtherEsHost>/<OtherEsIndex> --type=data --limit 10000

 

type是ES数据导出导入类型,Elasticdum工具支持以下数据类型的导入导出——
mapping ES的索引映射结构数据
data ES的数据
settings ES的索引库默认配置
limit 从SOURCE备份到DESTINATION的对象数量,默认是100,可自定义设置

 

参考:

https://help.aliyun.com/zh/es/use-cases/use-elasticsearch-dump-to-migrate-data?spm=a2c4g.11186623.0.0.317b7c67NLpasX

https://www.cnblogs.com/zhujiqian/p/14641972.html








posted on 2024-07-19 14:38  小油2018  阅读(1)  评论(0编辑  收藏  举报