阿里OSS、華為OBS和MinIO都兼容S3,所以可以通過ES的S3插件將快照進行備份
1、先安裝S3的插件
插件地址:https://artifacts.elastic.co/downloads/elasticsearch-plugins/repository-s3/repository-s3-7.8.0.zip
在線安裝太慢,所以手工將zip文件下載到服務器上進行安裝。
/usr/local/software/elasticsearch/bin/elasticsearch-plugin install file:///usr/local/repository-s3-7.8.0.zip
2、配置OSS的AK和SK
/usr/local/software/elasticsearch/bin/elasticsearch-keystore add s3.client.default.access_key
/usr/local/software/elasticsearch/bin/elasticsearch-keystore add s3.client.default.secret_key
注意:配置完OSS的AK和SK后,elasticsearch/config/elasticsearch.keystore 這個文件的權限會發生變化,在su es用戶啟動時會提示沒權限,所以要把elasticsearch.keystore權限配置好,我這里為了省事兒直接 chmod 777 elasticsearch.keystore
配置完AK和SK后重啟一下服務。
3、創建一個S3類型的倉庫
PUT http://x.x.x.x:9200/_snapshot/s3_obs_repository
{ "type": "s3", "settings": { "bucket": "xxxxx", #桶名
"base_path": "xxxxx", #桶中的哪個目錄 "endpoint": "oss-cn-xxxx.aliyuncs.com" #桶的endpoint } }
成功會返回:
{ "acknowledged": true }
4、開始做快照
PUT http://x.x.x.x:9200/_snapshot/s3_obs_repository/snapshot_20200813?wait_for_completion=true
成功后查看OBS中會出現快照文件