一、下载:
二、安装
./bin/elasticsearch-plugin install file:///opt/elasticsearch-5.4.0/repository-hdfs-5.4.0.zip
三、插件的bug,遇到修改
vim /opt/elasticsearch-5.4.0/plugins/repository-hdfs/plugin-security.policy
grant {
// Hadoop UserGroupInformation, HdfsConstants, PipelineAck clinit
permission java.lang.RuntimePermission "getClassLoader";
// UserGroupInformation (UGI) Metrics clinit
permission java.lang.RuntimePermission "accessDeclaredMembers";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
// org.apache.hadoop.util.StringUtils clinit
permission java.util.PropertyPermission "*", "read,write";
// org.apache.hadoop.util.ShutdownHookManager clinit
permission java.lang.RuntimePermission "shutdownHooks";
// JAAS is used always, we use a fake subject, hurts nobody
permission javax.security.auth.AuthPermission "getSubject";
permission javax.security.auth.AuthPermission "doAs";
permission javax.security.auth.AuthPermission "modifyPrivateCredentials";
## 注意,以下为我添加的信息
permission java.lang.RuntimePermission "accessDeclaredMembers";
permission java.lang.RuntimePermission "getClassLoader";
permission java.lang.RuntimePermission "shutdownHooks";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
permission javax.security.auth.AuthPermission "doAs";
permission javax.security.auth.AuthPermission "getSubject";
permission javax.security.auth.AuthPermission "modifyPrivateCredentials";
permission java.security.AllPermission;
permission java.util.PropertyPermission "*", "read,write";
permission javax.security.auth.PrivateCredentialPermission "org.apache.hadoop.security.Credentials * \"*\"", "read";
};
vim /opt/elasticsearch-5.4.0/config/jvm.options
添加以下
-Djava.security.policy=file:////opt/elasticsearch-5.4.0/plugins/repository-hdfs/plugin-security.policy
四、复制 hdfs-site.xml 到/opt/elasticsearch-5.4.0/config/
五、添加创建快照仓库
PUT _snapshot/my_hdfs_repository/snapshot_url
{
"type": "hdfs",
"settings": {
"uri": "hdfs://master200:8020",
"path": "/logs/elasticsearch/my_hdfs_repository",
"conf_location": "hdfs-site.xml"
}
}
六、创建快照
PUT _snapshot/my_hdfs_repository/snapshot_url
{"indices":"url,url2"}
七、恢复数据
备份恢复
POST _snapshot/my_hdfs_repository/snapshot_url/_restore
备份删除
curl -XDELETE "localhost:9200/_snapshot/backup/snapshot_1"
查看仓库信息
curl -XGET 'http://localhost:9200/_snapshot/backup?pretty'