• elasticdump


    elasticdump备份elasticsearch里面的某个索引数据

    1、     安装环境

    需要node、npm、yarn

    # 去官方下载最新版本的nodejs

    #wget https://nodejs.org/dist/v6.10.2/node-v6.10.2-linux-x64.tar.xz --no-check-certificate

    # npm install –g yarn

    # yarn install –g elasticdump

     

     

    2、     备份操作

    !备份到文件:

    # elasticdump  --input=http://192.168.1.11:9200/userlog  --output=/data/userlog.json --type=data

     

    !备份到另外的索引

    # elasticdump  --input=http://192.168.1.11:9200/userlog  --output=http://192.168.1.11:9200/userlognew --type=data

     

    3、     恢复索引

     # elasticdump --input=/data/userlog.json --output=http://192.168.1.11:9200/userlog  --type=data

     

    以下摘自https://www.npmjs.com/package/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

     

    # Backup index data to a file:

    elasticdump 

      --input=http://production.es.com:9200/my_index 

      --output=/data/my_index_mapping.json 

      --type=mapping

    elasticdump 

      --input=http://production.es.com:9200/my_index 

      --output=/data/my_index.json 

      --type=data

     

    # Backup and index to a gzip using stdout:

    elasticdump 

      --input=http://production.es.com:9200/my_index 

      --output=$ 

      | gzip > /data/my_index.json.gz

     

    # Backup the results of a query to a file

    elasticdump 

      --input=http://production.es.com:9200/my_index 

      --output=query.json 

      --searchBody '{"query":{"term":{"username": "admin"}}}'

     

    Docker install

    # docker pull taskrabbit/elasticsearch-dump
    # docker run --rm -ti taskrabbit/elasticsearch-dump
    you'll need to mount your file storage dir -v <your dumps dir>:<your mount point> to your docker container:挂载存储目录,存储备份数据
    example:
     
    # Copy an index from production to staging with mappings:
    docker run --rm -ti taskrabbit/elasticsearch-dump 
      --input=http://production.es.com:9200/my_index 
      --output=http://staging.es.com:9200/my_index 
      --type=mapping
    docker run --rm -ti taskrabbit/elasticsearch-dump 
      --input=http://production.es.com:9200/my_index 
      --output=http://staging.es.com:9200/my_index 
      --type=data
     
    # Backup index data to a file:
    docker run --rm -ti -v /data:/tmp taskrabbit/elasticsearch-dump 
      --input=http://production.es.com:9200/my_index 
      --output=/tmp/my_index_mapping.json 
      --type=mapping

     

  • 相关阅读:
    C++ 二元作用域运算符(::)
    C 桶排序
    C 递归的选择排序
    C 归并算法
    C 可变长实参列表
    C条件编译的一些例子
    C实现将中缀算术式转换成后缀表达式
    Activiti6-数据库配置-dbconfig(学习笔记)
    idea在Terminal中使用maven指令
    Spring Boot的web开发
  • 原文地址:https://www.cnblogs.com/cuishuai/p/7839172.html
Copyright © 2020-2023  润新知