zoukankan      html  css  js  c++  java
  • 基于docker使用elasticsearch-dump,es数据导入导出

    1.拉去dump镜像

    [root@localhost ~]# docker pull taskrabbit/elasticsearch-dump
     

    2.相关实例

    1.创建文件存放路径

    [root@localhost ~]# mkdir -p /data/
    2.将索引数据备份到文件

    [root@localhost ~]# docker run --rm -ti -v /data/:/tmp taskrabbit/elasticsearch-dump --input=http://192.168.1.2:9200/my_index --output=/tmp/dump.json --type=data
     

    3.将旧环境数据导入到新环境

    [root@localhost ~]# docker run --rm -ti elasticsearch-dump --input=http://192.168.1.2:9200/my_index --output=http://192.168.1.2:9200/my_index --type=data
    3.将文件导入到es数据库中

    [root@localhost ~]# docker run --rm -ti -v /data:/tmp taskrabbit/elasticsearch-dump --input=/tmp/dump.json --output=http://192.168.1.2:9200/my_index --type=data
     

    官方文档:https://github.com/taskrabbit/elasticsearch-dump?utm_source=dbweekly&utm_medium=email

     上面写的只是导入导出es的数据的,如果要把es的索引结构和mapping还有数据导出可以用下面方式:

    导出es的mapping 

    docker run --rm -ti -v /root/es_dump_data/:/tmp taskrabbit/elasticsearch-dump --input=http://15.31.213.92:9200/dw_task_progress_index --output=/tmp/dw_task_progress_index_mapping.json --type=mapping

    导出analyzer(没有分词就不需要)

    docker run --rm -ti -v /root/es_dump_data/:/tmp taskrabbit/elasticsearch-dump --input=http://15.31.213.92:9200/dw_task_progress_index --output=/tmp/dw_task_progress_index_analyzer.json --type=analyzer

    导出es数据

    docker run --rm -ti -v /root/es_dump_data/:/tmp taskrabbit/elasticsearch-dump --input=http://15.31.213.92:9200/dw_task_progress_index --output=/tmp/dw_task_progress_index.json --type=data

     删除索引

    curl -XDELETE http://15.31.213.44:9200/dw_task_progress_index

    创建索引

    curl -XPUT http://15.31.213.44:9200/dw_task_progress_index -d '
    {

    "settings": {
    "index": {
    "number_of_shards": "3",
    "number_of_replicas": "1"
    }
    }

    }
    '

    导入mapping

    docker run --rm -ti -v /root/es_dump_data:/tmp taskrabbit/elasticsearch-dump --input=/tmp/dw_task_progress_index_mapping.json --output=http://15.31.213.44:9200/ --type=mapping

    导入analyzer(没有分词就不需要)

    docker run --rm -ti -v /root/es_dump_data:/tmp taskrabbit/elasticsearch-dump --input=/tmp/dw_task_progress_index_analyzer.json --output=http://15.31.213.44:9200/ --type=analyzer

    导入data

     docker run --rm -ti -v /root/es_dump_data:/tmp taskrabbit/elasticsearch-dump --input=/tmp/dw_task_progress_index.json --output=http://15.31.213.44:9200/ --type=data

  • 相关阅读:
    IE内核浏览器下中文双引号自动显示成英文引号的说明
    【转】Linq初体验——Order By 通过属性名动态排序
    【转】Windows8不联网直接安装.Net 3.5 Framework的方法
    DrawImage在绘制图片的时候,为什么会擅自改变图片的大小?
    用js判断.net版本
    【转】html 页面打印并 分页
    利用IE9下载网络歌曲新法
    LINQ访问DataTable
    20165205与20165233结对感想以及创意照
    20165233 Java第一章学习总结
  • 原文地址:https://www.cnblogs.com/xiaohanlin/p/12103679.html
Copyright © 2011-2022 走看看