ES数据迁移

发布时间 2023-11-03 17:01:33作者: RemMai

ES数据迁移

  1. 安装nodejs
  2. 安装elasticdump, npm install elasticdump -g
    主要参数说明:
    --input: 源地址,可为ES集群URL、文件或stdin,可指定索引,格式为:{protocol(http协议)}: //{host}:{port}/{index}
    --input-index: 源ES集群中的索引
    --output: 目标地址,可为ES集群地址URL、文件或stdout,可指定索引,格式为:{protocol(http协议)}: //{host}:{port}/{index}
    --output-index: 目标ES集群的索引
    --type: 迁移类型,默认为data,表明只迁移数据,可选settings, analyzer, data, mapping, alias
    --limit:每次向目标ES集群写入数据的条数,不可设置的过大,以免bulk队列写满
  3. 命令
# --input:你要从哪里导出,
# --output:目标路径

elasticdump --input=http://源IP地址:9200/索引名称 --output=http://目标IP地址:9200/索引名称 --type=settings
elasticdump --input=http://源IP地址:9200/索引名称 --output=http://目标IP地址:9200/索引名称 --type=mapping
elasticdump --input=http://源IP地址:9200/索引名称 --output=http://目标IP地址:9200/索引名称 --type=data
  1. 查看源ES有哪些索引
curl -XGET http://源IP地址:9200/_cat/indices?pretty

或 网页打开 http://源IP地址:9200/_cat/indices?pretty

  1. 验证
curl -XGET http://目标IP地址:9200/索引名称/_search

或 网页打开 http://目标IP地址:9200/索引名称/_search