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

 

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

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

1、docker 安装 

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

es 索引导出导入(elasticsearch-dump) docker方式_第1张图片

2、启动docker

命令:service docker start

3、安装 elasticsearch-dump

命令:docker pull taskrabbit/elasticsearch-dump

es 索引导出导入(elasticsearch-dump) docker方式_第2张图片

到此就安装成功了。

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 : 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  -o 

例如

$ 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
                            79ee919b2a0a        2 days ago          138MB

添加名字

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

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

你可能感兴趣的:(es,docker)