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

  • 相关阅读:
    github克隆镜像
    python2安装pip(get-pip.py)和pip更新源
    GitHack使用—create_unverified_context报错
    XCTF:shrine(Flask模块注入)
    开机自启动(C#)
    操作xml(C#)
    隐藏到托盘(C#)
    火狐浏览器下请求两次(C#)
    Nancy学习笔记
    jquery纵向抽屉式导航栏
  • 原文地址:https://www.cnblogs.com/fsckzy/p/15545465.html
Copyright © 2011-2022 走看看