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

  • 相关阅读:
    Java并发编程基本概念
    详解TCP:顺序和丢包问题
    详解TCP:三次握手、四次挥手
    使用DockerFile构建运行GoWeb
    Go之Gorm和BeegoORM简介及配置使用
    Nginx WebUI管理
    Kibana配置nginx反代并本地ca加密nginx
    07 . ELK Stack7.2一键多机部署脚本
    腾讯蓝鲸自动化运维平台简介部署及常见报错解决
    Go操作Redis
  • 原文地址:https://www.cnblogs.com/xiaohanlin/p/12103679.html
Copyright © 2011-2022 走看看