zoukankan      html  css  js  c++  java
  • 使用elasticdump做数据迁移


    es版本
    [root@localhost bin]# ./elasticdump --help
    elasticdump: Import and export tools for elasticsearch
    version: 4.6.0

    1.elasticdump

    安装
    su - root
    cd /opt
    yum install epel-release
    yum install nodejs
    yum install npm
    npm install elasticdump
    cd node_modules/elasticdump/bin  后便可以执行操作。

    #拷贝analyzer如分词
    ./elasticdump
      --input=http://192.168.1.85:9200/db_customer
      --output=http://192.168.1.118:9200/db_customer
      --type=analyzer

    #拷贝映射
    ./elasticdump
      --input=http://192.168.1.85:9200/db_customer
      --output=http://192.168.1.118:9200/db_customer
      --type=mapping

    #拷贝数据
    ./elasticdump
      --input=http://192.168.1.85:9200/db_customer
      --output=http://192.168.1.118:9200/db_customer
      --type=data

    带验证的导入

    ./elasticdump
      --input=http://elastic:elastic@192.168.1.134:29200/db_customer
      --output=http://elastic:elastic@192.168.1.118:9200/db_customer
      --type=analyzer

    #拷贝映射
    ./elasticdump
      --input=http://elastic:elastic@192.168.1.134:29200/db_customer
      --output=http://elastic:elastic@192.168.1.118:9200/db_customer
      --type=mapping

    #拷贝数据
    ./elasticdump
      --input=http://elastic:elastic@192.168.1.134:29200/db_customer
      --output=http://elastic:elastic@192.168.1.118:9200/db_customer
      --type=data


    ------------------------原封不动的迁移----------------------------------------------
    #拷贝分词
    ./elasticdump --input=http://192.168.1.136:19200/hxl_test --output=http://192.168.1.136:19200/bak01_hxl_test --type=analyzer


    #拷贝映射
    ./elasticdump --input=http://192.168.1.136:19200/hxl_test  --output=http://192.168.1.136:19200/bak01_hxl_test --type=mapping


    #拷贝数据
    ./elasticdump --input=http://192.168.1.136:19200/hxl_test --output=http://192.168.1.136:19200/bak01_hxl_test --type=data

    ----------------------------提前创建索引后,只迁移数据------------------------
    1.提前创建索引,结构可以跟源库的有一定的差异
    比如在原来索引的基础上添加了"type": "nested"
    2.同步数据
    /opt/node_modules/elasticdump/bin/elasticdump --input=http://192.168.1.136:19200/inoculate --output=http://192.168.1.136:19200/inoculate_new --type=data

    ​遇到的错误:
    ​/opt/node_modules/elasticdump/lib/processor.js:40
      async _loop (limit, offset, totalWrites) {
            ^^^^^

    SyntaxError: Unexpected identifier
        at createScript (vm.js:56:10)
        at Object.runInThisContext (vm.js:97:10)
        at Module._compile (module.js:549:28)
        at Object.Module._extensions..js (module.js:586:10)
        at Module.load (module.js:494:32)
        at tryModuleLoad (module.js:453:12)
        at Function.Module._load (module.js:445:3)
        at Module.require (module.js:504:17)
        at require (internal/module.js:20:19)
        at Object.<anonymous> (/opt/node_modules/elasticdump/elasticdump.js:3:28)
    [root@yeemiao-oracle-9e96168-prd bin]#
    [root@yeemiao-oracle-9e96168-prd bin]# npm install -g n
    /usr/bin/n -> /usr/lib/node_modules/n/bin/n
    /usr/lib
    └── n@6.0.1

    [root@yeemiao-oracle-9e96168-prd bin]# /opt/node_modules/elasticdump/bin/elasticdump --input=http://172.17.10.20:19200/child_inocexamine_student --output=http://172.17.10.61:29200/child_inocexamine_student --type=analyzer
    /opt/node_modules/elasticdump/lib/processor.js:40
      async _loop (limit, offset, totalWrites) {
            ^^^^^

    SyntaxError: Unexpected identifier
        at createScript (vm.js:56:10)
        at Object.runInThisContext (vm.js:97:10)
        at Module._compile (module.js:549:28)
        at Object.Module._extensions..js (module.js:586:10)
        at Module.load (module.js:494:32)
        at tryModuleLoad (module.js:453:12)
        at Function.Module._load (module.js:445:3)
        at Module.require (module.js:504:17)
        at require (internal/module.js:20:19)
        at Object.<anonymous> (/opt/node_modules/elasticdump/elasticdump.js:3:28)
        
    解决办法:
    #升级nodejs
    [root@localhost ~]# npm install -g n
    [root@localhost ~]# n latest

  • 相关阅读:
    SQLite 与 SqlCE 比较
    window.showModalDialog以及window.open用法简介
    Flex 3D Engine演示 帅呆了。
    MySQLFront
    数据库复制相同表语句
    org.jboss.web.jsf.integration.config.JBossJSFConfigureListener
    PHP中全局变量$_SERVER的详细用法
    PHP date函数使用说明
    如何学习Flex Framework
    richfaces a4j标签帮助文档 地址
  • 原文地址:https://www.cnblogs.com/hxlasky/p/11687318.html
Copyright © 2011-2022 走看看