es 索引导出导入(elasticsearch-dump) docker方式

1 篇文章 0 订阅

 

elasticsearch-dump提供两种安装方式,如下:

推荐使用docker,不需要解决环境依赖问题。

1、docker 安装 

命令:wget -qO- https://get.docker.com/ | sh

2、启动docker

命令:service docker start

3、安装 elasticsearch-dump

命令:docker pull taskrabbit/elasticsearch-dump

到此就安装成功了。

4、使用

Docker install

If you prefer using docker to use elasticdump, you can download this project from docker hub :

docker pull taskrabbit/elasticsearch-dump

Then you can use it just by :

  • using 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=data

If you need to run using localhost as your ES host :

docker run --net=host --rm -ti taskrabbit/elasticsearch-dump \
  --input=http://staging.es.com:9200/my_index \
  --output=http://localhost:9200/my_index \
  --type=data

Dump Format

The file format generated by this tool is line-delimited JSON files. The dump file itself is not valid JSON, but each line is. We do this so that dumpfiles can be streamed and appended without worrying about whole-file parser integrety.

For example, if you wanted to parse every line, you could do:

while read LINE; do jsonlint-py "${LINE}" ; done < dump.data.json

离线环境安装(ubuntu  xenial)https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/

docker安装:下载下面文件,先后顺序安装

dpkg -i containerd.io_1.2.6-3_amd64.deb

dpkg -i docker-ce-cli_19.03.3~3-0~ubuntu-xenial_amd64.deb

dpkg -i  docker-ce_19.03.3~3-0~ubuntu-xenial_amd64.deb

将已经有的image导出

导出image

$ docker save <imageid> -o <imagefile.tar>

例如

$ docker save 3c5cf79640a3 -o elasticsearch-dump.tar

 导入

root@ubuntu:/home/devops# docker load -i elasticsearch-dump.tar 
f1b5933fe4b5: Loading layer [==================================================>]  5.796MB/5.796MB
a3b85ad42b98: Loading layer [==================================================>]  69.33MB/69.33MB
77306e58a4bd: Loading layer [==================================================>]   5.53MB/5.53MB
dd108d5734de: Loading layer [==================================================>]  3.584kB/3.584kB
a70c74be0eca: Loading layer [==================================================>]   65.8MB/65.8MB
50e7162722b9: Loading layer [==================================================>]  3.584kB/3.584kB
Loaded image ID: sha256:79ee919b2a0ab9dcea42ae4f5c4b8d3f0e79486bc46cc99c23bfbac37004ea85

查看

root@ubuntu:/home/devops# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
<none>              <none>              79ee919b2a0a        2 days ago          138MB

添加名字

root@ubuntu:/home/devops# docker tag 79ee919b2a0a taskrabbit/elasticsearch-dump

现在可以像在线安装一样使用了

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值