zoukankan      html  css  js  c++  java
  • 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

     

  • 相关阅读:
    linux软件安装方式
    docker 安装 jenkins touch: cannot touch ‘/var/jenkins_home/copy_reference_file.log’: Permission denied Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?
    [ERR] Node goodsleep.vip:6379 is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0.
    Linux 常用命令 服务器间scp 用户 export 创建文件、软连接
    redis 安装 集群 主从 哨兵 docker
    WPF密码框中禁止复制、粘贴
    Application 统计在线人数
    【转义字符】HTML 字符实体&lt; &gt: &amp;等
    SQL语句统计每天的数据
    正则表达式计算代码数
  • 原文地址:https://www.cnblogs.com/cuishuai/p/7839172.html
Copyright © 2011-2022 走看看