ES的Hadoop插件,总共有3个,我们要使用的是 hadoop HDFS Snapshot/Restore plugin,它主要用于备份ES数据到HDFS,或者从HDFS恢复数据,也就是ES的snapshot/restore特性。还原可以还原到别的集群,集群名字和节点数量不一样都可以,也就是 可以做 数据迁移
安装插件
1
|
bin
/plugin
-i elasticsearch
/elasticsearch-repository-hdfs/2
.0.2
|
这里hadoop的版本一定要对应好,否则后面会失败的。如果自动不能安装,可以手动去库里面下载,然后放到ES插件目录下面。
创建配置
1
2
3
4
5
6
7
8
|
curl -XPUT
'http://localhost:9200/_snapshot/my_backup'
-d '{
"type"
:
"hdfs"
,
"settings"
: {
"uri"
:
"hdfs://myhadoop:8020"
,
"path"
:
"/es"
,
"conf_location"
:
"hdfs-site.xml"
}
}'
|
1
|
{
"acknowledged"
:
true
}
#返回这个表示创建成功
|
通过下面的命令,可以查看所有创建的配置
1
|
curl http:
//localhost
:9200
/_snapshot/_all
|
备份数据
1
|
curl -XPUT
"localhost:9200/_snapshot/my_backup/snapshot_1?wait_for_completion=true"
|
备份成功,我们可以在 http://myhadoop:50070/explorer.html#/es 下面看到我们创建的备份
还原数据
1
|
curl -XPOST
"localhost:9200/_snapshot/my_backup/snapshot_1/_restore?wait_for_completion=true"
|