zoukankan      html  css  js  c++  java
  • elasticsearch7.15.1迁移索引记录 海口

    背景

    因业务需要将旧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

  • 相关阅读:
    【leetcode】Reverse Nodes in k-Group (hard)☆
    JSP简单练习-包装类综合应用实例
    C++ 学习笔记3,struct长度測试,struct存储时的对齐方式
    rsh 无秘钥登陆配置
    【POJ 3122】 Pie (二分+贪心)
    Boss OpenCart 商城自适应主题模板 ABC-0012-01
    理解C语言中指针的声明以及复杂声明的语法
    JQuery编程demo练习
    Growth: 一个关于怎样成为优秀Web Developer 的 App
    改动select默认样式,兼容IE9
  • 原文地址:https://www.cnblogs.com/fsckzy/p/15545465.html
Copyright © 2011-2022 走看看