文章目录
1. 配置备份
1.1. 安装repository-s3插件
每个Elasticsearch节点都要安装,若数据库已启动需要重启节点;若其他相同版本的集群Elasticsearch节点已安装repository-s3插件,可以从其他节点直接拷贝。
# elasticsearch-plugin install repository-s3
1.2. 配置JVM参数
在创建对象存储之前,需要在 jvm.options 中添加参数:
# vim jvm.options
新增如下配置:
-Des.allow_insecure_settings=true
1.3. 申请对象存储
若使用讯飞云对象存储,可到讯飞云官网进行申请。创建快照仓库时,需要下表的accessKey和secretKey,不需要AccessKeyID和AccessKeySecret。
AccessKey ID | accessKey | AccessKey Secret | secretKey | bucket | endpoint | base_path | 状态 |
---|---|---|---|---|---|---|---|
************* | ********************* | ************************** | ************************************* | <bucket_name> | http://<endpoint_IP>:<endpoint_PORT> | <bucket_name> | 启用 |
1.4. 创建快照仓库
1)测试endpoint的连通性
# telnet <endpoint_host> <endpoint_port>
Trying <endpoint_host>...
Connected to <endpoint_host>.
Escape character is '^]'.
^]
telnet> quit
Connection closed.
2)创建快照仓库,快照仓库名为<snapshot_warehouse_name>
快照保存它创建的时间点上所有跟集群相关的数据,包括集群状态和索引的信息。在创建第一个快照之前,必须创建一个快照存储库。
# curl -H "Content-Type: application/json" -XPUT 'http://<elasticsearch_host>:<elasticsearch_port>/_snapshot/<snapshot_warehouse_name>' -d '
{
"type": "s3",
"settings": {
"endpoint": "http://<endpoint_IP>:<endpoint_PORT>",
"access_key": "*********************",
"secret_key": "*************************************",
"bucket": "<bucket_name>",
"base_path" : "<bucket_name>",
"chunk_size" : "200mb",
"max_restore_bytes_per_sec" : "50mb",
"max_snapshot_bytes_per_sec" : "50mb",
"compress": true
}
}'
请注意:若提供的"access_key"和"secret_key"不正确的话,会报如下错误:
{
"error": {
"root_cause": [{
"type": "blob_store_exception",
"reason": "Failed to check if blob [master.dat-temp] exists"
}],
"type": "blob_store_exception",
"reason": "Failed to check if blob [master.dat-temp] exists",
"caused_by": {
"type": "amazon_s3_exception",
"reason": "Forbidden (Service: Amazon S3; Status Code: 403; Error Code: 403 Forbidden; Request ID: tx00000000000002241b610-0060a6b117-8efa7e-default; S3 Extended Request ID: null)"
}
},
"status": 500
}
3)确认备份仓库是否创建成功
# curl -H "Content-Type: application/json" -XPOST http://<elasticsearch_host>:<elasticsearch_port>/_snapshot/<snapshot_warehouse_name>/_verify?pretty
{
"nodes" : {
"c4caXoXdT1iaKt8Q0j4zvA" : {
"name" : "elasticsearch_node1"
},
"V8J66mq3ScaatOh-b9u0Fw" : {
"name" : "elasticsearch_node2"
},
"mzRuQoWKS1qaedpo1cBslQ" : {
"name"