1.对于elasticdump?
elasticdump原理
- elasticdump是实现不同ElasticSearch集群之间索引迁徙的工具。默认状况下,ITOA集群部署胜利后,该工具存在于装置节点(客户端节点)上。
- 不同ElasticSearch集群之间要实现索引数据的转移,须要应用到elasticdump工具。
- 要实现ElasticSearch的数据迁徙,除了要实现索引中文档对象的迁徙外,还须要迁徙索引中映射模式的迁徙。对于某一个索引的映射信息能够通过ElasticSearch中的_plugin/head插件在web界面通过信息中的索引信息来查阅。如图1所示
2.elasticdump应用形式
通过npm装置elasticdump
#本地装置和全局装置的区别在于它是否主动给你设置环境变量,其余的没有区别# 本地装置$ npm install elasticdump$ ./bin/elasticdump# 全局装置$ npm install elasticdump -g$ elasticdump
操作示例:导出
#格局:elasticdump --input {protocol}://{host}:{port}/{index} --output ./test_index.json#例子:将ES中的test_index 中的索引导出#导出以后索引的mapping构造$ elasticdump --input http://192.168.56.104:9200/test_index --output ./test_index_mapping.json --type=mapping#导出以后索引下的所有实在数据$ elasticdump --input http://192.168.56.104:9200/test_index --output ./test_index.json --type=data
操作示例:导入
# 创立索引$ 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
通过docker镜像应用elasticdump
# 镜像下载$ docker pull taskrabbit/elasticsearch-dump# 上面还是例子:通过镜像导出数据到本地# 创立一个文件夹用于保留导出数据$ mkdir -p /root/data# 上面须要对门路进行映射并执行命令(导出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 -----------------------------------------------------------------------------# 以下内容为ES -> ES的数据迁徙例子$ 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
3.如果须要操作的es集群配置了xpack平安认证
在对应的http前面,增加user:password@
docker run --rm -ti elasticsearch-dump --input=http://192.168.1.2:9200/my_index --output=http://user:password@192.168.1.2:9200/my_index --type=data
附录:
https://www.cnblogs.com/mojit...
https://github.com/elasticsea...