Elasticsearch导入导出数据-Elasticdump

1 导入/导出

导出:

1
2
3
4
#因为导出的是mapping,所以设置type为mapping
$ elasticdump --input http://192.168.56.105:9200/ --output ./test_index_mapping.json --type=mapping
#因为导出的是data(真实数据)所以设置type为data
$ elasticdump --input http://192.168.56.105:9200/ --output ./test_index.json --type=data

导入:

1
2
3
4
5
6
# 创建索引
$ curl -XPUT http://192.168.56.104:9200/test_index
#因为导入的是mapping,所以设置type为mapping
$ elasticdump --input ./test_index_mapping.json --output http://192.168.56.105:9200/ --type=mapping
#因为导入的是data(真实数据)所以设置type为data
$ elasticdump --input ./test_index.json --output http://192.168.56.105:9200/ --type=data

2 使用Elasticdump镜像进行数据导入/导出

1
2
3
4
5
# 镜像下载
$ docker pull taskrabbit/elasticsearch-dump
# 下面还是例子:通过镜像导出数据到本地
# 创建一个文件夹用于保存导出数据
$ mkdir -p /root/data

导出

1
2
3
4
5
6
7
8
9
10
# 下面需要对路径进行映射并执行命令(导出mapping)
$ 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
# 导出(data)
$ docker run --rm -ti -v /root/data:/tmp taskrabbit/elasticsearch-dump \
--input=http://192.168.56.104:9200/test_index \
--output=/tmp/elasticdump_export.json \
--type=data

导入

1
2
3
4
5
6
7
8
9
10
11
12
# 创建索引
$ curl -XPUT http://192.168.56.104:9200/test_index
# 导入mapping
$ docker run --rm -ti -v /data:/tmp taskrabbit/elasticsearch-dump \
--input=/tmp/my_index_mapping.json \
--output=http://192.168.56.104:9200/my_index \
--type=mapping
# 导入(data)
$ docker run --rm -ti -v /root/data:/tmp taskrabbit/elasticsearch-dump \
--input=/tmp/elasticdump_export.json \
--output=http://192.168.56.104:9200/test_index \
--type=data

3 以下内容为ES -> ES的数据迁移例子

1
2
3
4
5
6
7
8
9
$ 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
-------------本文结束感谢您的阅读-------------

本文标题:Elasticsearch导入导出数据-Elasticdump

文章作者:OperationMAN

发布时间:2022年01月12日 - 12:01

最后更新:2022年06月05日 - 21:06

原始链接:https://kxinter.gitee.io/2022/01/12/Elasticsearch导入导出数据-Elasticdump/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

坚持原创技术分享,您的支持将鼓励我继续创作!