基于docker使用elasticsearch-dump,es数据导入导出


 

1.拉去dump镜像

[root@localhost ~]# docker pull taskrabbit/elasticsearch-dump
 

2.相关实例

1.创建文件存放路径

[root@localhost ~]# mkdir -p /data/
2.将索引数据备份到文件

[root@localhost ~]# docker run --rm -ti -v /data/:/tmp taskrabbit/elasticsearch-dump --input=http://192.168.1.2:9200/my_index --output=/tmp/dump.json --type=data
 

3.将旧环境数据导入到新环境

[root@localhost ~]# docker run --rm -ti elasticsearch-dump --input=http://192.168.1.2:9200/my_index --output=http://192.168.1.2:9200/my_index --type=data
3.将文件导入到es数据库中

[root@localhost ~]# docker run --rm -ti -v /data:/tmp taskrabbit/elasticsearch-dump --input=/tmp/dump.json --output=http://192.168.1.2:9200/my_index --type=data
 

官方文档:https://github.com/taskrabbit/elasticsearch-dump?utm_source=dbweekly&utm_medium=email

 

 

 上面写的只是导入导出es的数据的,如果要把es的索引结构和mapping还有数据导出可以用下面方式:

 

导出es的mapping 

docker run --rm -ti -v /root/es_dump_data/:/tmp taskrabbit/elasticsearch-dump --input=http://15.31.213.92:9200/dw_task_progress_index --output=/tmp/dw_task_progress_index_mapping.json --type=mapping

 

导出analyzer(没有分词就不需要)

docker run --rm -ti -v /root/es_dump_data/:/tmp taskrabbit/elasticsearch-dump --input=http://15.31.213.92:9200/dw_task_progress_index --output=/tmp/dw_task_progress_index_analyzer.json --type=analyzer

 

导出es数据

docker run --rm -ti -v /root/es_dump_data/:/tmp taskrabbit/elasticsearch-dump --input=http://15.31.213.92:9200/dw_task_progress_index --output=/tmp/dw_task_progress_index.json --type=data

 

 删除索引

curl -XDELETE http://15.31.213.44:9200/dw_task_progress_index

 

创建索引

curl -XPUT http://15.31.213.44:9200/dw_task_progress_index -d '
{

"settings": {
"index": {
"number_of_shards": "3",
"number_of_replicas": "1"
}
}

}
'

 

导入mapping

docker run --rm -ti -v /root/es_dump_data:/tmp taskrabbit/elasticsearch-dump --input=/tmp/dw_task_progress_index_mapping.json --output=http://15.31.213.44:9200/ --type=mapping

 

导入analyzer(没有分词就不需要)

docker run --rm -ti -v /root/es_dump_data:/tmp taskrabbit/elasticsearch-dump --input=/tmp/dw_task_progress_index_analyzer.json --output=http://15.31.213.44:9200/ --type=analyzer

 

导入data

 docker run --rm -ti -v /root/es_dump_data:/tmp taskrabbit/elasticsearch-dump --input=/tmp/dw_task_progress_index.json --output=http://15.31.213.44:9200/ --type=data

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM