Decoupling Index Storage and Compute in an Elasticsearch Cluster Through Index Lifecycle Management
Overview
CSS supports decoupled storage and compute. That is, indexes can be frozen in OBS to reduce the storage cost of cold data. This document describes how to use index lifecycle management to automatically freeze indexes at a specific time to decouple storage and compute.
In this section, a lifecycle policy is configured to automatically freeze an index three days after it is created and dump data to OBS. The index will be deleted seven days after it is created.
Prerequisites
- There are available CSS clusters.
- Elasticsearch 7.6.2 clusters or later are used.
Decoupling Index Storage and Compute Through Index Lifecycle Management
- Log in to the CSS management console.
- In the navigation tree on the left, choose Clusters > Elasticsearch. The cluster list is displayed.
- Click Access Kibana in the Operation column of a cluster.
- In the navigation tree on the left of Kibana, choose Dev Tools. The command execution page is displayed.
- Create a lifecycle policy named hot_warm_policy.
Policy description: Three days after an index is created, the API for freezing the index is automatically called to dump data to OBS. Seven days after an index is created, the index is deleted.
PUT _opendistro/_ism/policies/hot_warm_policy { "policy": { "description": "hot warm delete workflow", "error_notification": null, "default_state": "hot", "states": [ { "name": "hot", "actions": [], "transitions": [ { "state_name": "warm", "conditions": { "min_index_age": "3d" } } ] }, { "name": "warm", "actions": [ { "freeze_low_cost": {} } ], "transitions": [ { "state_name": "delete", "conditions": { "min_index_age": "7d" } } ] }, { "name": "delete", "actions": [ { "delete": {} } ], "transitions": [] } ] } }
- Create the index template template_hot_warm.
Template description: All the new indexes starting with data are automatically associated with the lifecycle policy hot_warm_policy.
PUT _template/template_hot_warm { "index_patterns": "data*", "settings": { "number_of_replicas": 5, "number_of_shards": 1, "opendistro.index_state_management.policy_id": "hot_warm_policy" }, "mappings": { "properties": { "name": { "type": "text" } } } }
Table 1 Parameter description Parameter
Description
number_of_shards
Number of index shards
number_of_replicas
Number of index shard replicas
opendistro.index_state_management.policy_id
Lifecycle policy name
- Create the data-2022-06-06 index. The index automatically uses the template_hot_warm template and associates the index template with the lifecycle policy hot_warm_policy. In this way, the index is frozen three days after creation and is deleted seven days after creation.
POST data-2022-06-06/_bulk {"index":{}} {"name":"name1"} {"index":{}} {"name":"name2"} {"index":{}} {"name":"name3"} {"index":{}} {"name":"name4"} {"index":{}} {"name":"name5"} {"index":{}} {"name":"name6"}
- Query data and check whether storage and compute is automatically decoupled.
- Three days after the index is created, check the frozen index.
GET _cat/freeze_indices?s=i&v
The index generated three days ago is expected to be frozen.
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size green open data-2022-06-06 x8ab5NX6T3Ox_xoGUanogQ 1 1 6 0 7.6kb 3.8kb
- Seven days after the index is created, check the frozen index. The index is expected to be deleted.
- Three days after the index is created, check the frozen index.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot