zoukankan      html  css  js  c++  java
  • 利用elasticsearch-dump实现es索引数据迁移附脚本

    1、安装环境

    CentOS Linux release 7.5.1804 (Core)
    
    • 1

    2、安装nodejs

    yum install -y nodejs
    
    • 1

    3、验证nodejs

    [root@localhost yum.repos.d]# node -v
    v8.12.0
    [root@localhost yum.repos.d]# npm -v
    6.4.1
    
    • 1
    • 2
    • 3
    • 4

    4、安装elasticsearch-dump

    npm install elasticdump
    
    • 1

    5、验证安装

    进入elasticdump/bin目录下

    cd node_modules/elasticdump/bin/
    
    • 1

    执行

     ./elasticdump
    
    • 1

    出现

    Fri, 19 Oct 2018 07:03:15 GMT | Error Emitted => {"errors":["`input` is a required input","`output` is a required input"]}
    
    • 1

    报错是因为没有输入参数

    6、使用dump迁移索引

    #拷贝索引

    elasticdump 
    	--input=http://production.es.com:9200/my_index 
    	--output=http://staging.es.com:9200/my_index 
    	--type=mapping
    
    • 1
    • 2
    • 3
    • 4

    #拷贝数据

    elasticdump 
    	--input=http://production.es.com:9200/my_index 
    	--output=http://staging.es.com:9200/my_index 
    	--type=data
    
    • 1
    • 2
    • 3
    • 4

    #拷贝所有索引

    elasticdump  
    	--input=http://production.es.com:9200/ 
    	--output=http://staging.es.com:9200/ 
    	--all=true  
    
    • 1
    • 2
    • 3
    • 4

    7、迁移实战

    为了方便操作写了一个脚本,仅供参考。

    #!/bin/bash
    echo -n "源ES地址: "
    read old
    echo -n "目标ES地址: "
    read new
    echo -n "源索引名: "
    read old_index
    echo -n "目标索引名: "
    read new_index
    cd /root/node_modules/elasticdump/bin/
     ./elasticdump --input=$old/$old_index  --output=$new/$new_index  --type=mapping &>> /root/dump.log
     ./elasticdump --input=$old/$old_index  --output=$new/$new_index  --type=data &>> /root/dump.log
  • 相关阅读:
    asp.net大文件断点续传
    JS大文件上传解决方案
    B/S大文件上传解决方案
    B/S上传整个文件夹
    网页上传整个文件夹
    POJ 1068 Parencodings
    74LS85 比較器 【数字电路】
    二叉树的建立与先序,后序,中序输出
    Android 学习之 开源项目PullToRefresh的使用
    理解矩阵及谱聚类小记
  • 原文地址:https://www.cnblogs.com/agang-php/p/11611769.html
Copyright © 2011-2022 走看看