Index ilm policy이란
ILM (Index Lifecycle Management)은 데이터 인덱스의 수명 주기를 관리하기 위한 기능입니다. ILM를 사용하면 데이터의 보존, 압축, 백업 및 삭제와 같은 다양한 관리 작업을 자동화하고 데이터 스토리지를 효율적으로 관리할 수 있는 기능을 제공하지만 이번 문서에서는 아주 간단하게 인덱스가 생성되고 일정 기간이 지나면 인덱스가 삭제되도록 하는 방법에 대하여 정리하였습니다.
보다 자세한 ILM 설명은 링크를 확인해주세요 (https://stdhsw.tistory.com/entry/Elasticsearch-%EC%B5%9C%EC%A0%81%ED%99%94-3-ilm-policy%EB%A1%9C-data-tiering-%ED%95%98%EA%B8%B0)
Index ilm policy 설정하기
PUT localhost:9200/_ilm/policy/my-policy
Content-Type: application/json
{
"policy": {
"phases": {
"delete": {
"min_age": "3d",
"actions": {
"delete": {}
}
}
}
}
}
ilm policy 파라미터
- delete.min_age : 인덱스가 생성되고 얼마만큼의 기간이 흐르면 지울지 설정합니다.
Index ilm policy 설정 확인 하기
GET localhost:9200/_ilm/policy/my-policy
### 결과
{
"my-policy": {
"version": 1,
"modified_date": "2023-10-25T09:43:53.527Z",
"policy": {
"phases": {
"delete": {
"min_age": "3d",
"actions": {
"delete": {
"delete_searchable_snapshot": true
}
}
}
}
},
"in_use_by": {
"indices": [],
"data_streams": [],
"composable_templates": []
}
}
}
ILM Policy를 Index template에 적용하기
인덱스 template에 ILM 설정을 적용합니다. 인덱스 template에 대한 자세한 설명은 링크를 확인해 주세요 (https://stdhsw.tistory.com/entry/Elasticsearch%EC%9D%98-Index-template-%EC%84%A4%EC%A0%95)
PUT http://localhost:9200/_template/my-index-template
Content-Type: application/json
{
"index_patterns": ["my-index*"],
"settings": {
"index": {
"number_of_shards": "2",
"number_of_replicas": "1",
"refresh_interval": "5s",
"lifecycle": {
"name": "my-policy"
}
}
},
"mappings": {
"properties": {
"app": {
"type": "keyword"
},
"level": {
"type": "keyword"
},
"message": {
"type": "text"
}
}
}
}
Index template 파라미터
- settings.index.lifecycle.name : 위에서 지정한 ILM의 명칭을 기입합니다.
위 설정을 적용하면 이제 "my-index"로 시작하는 모든 인덱스는 앞으로 생성되고 3일 뒤에 자동적으로 삭제가 되어 보다 효율적으로 디스크 사용량을 관리할 수 있습니다.
Index ilm policy 삭제하기
### delete
DELETE localhost:9200/_ilm/policy/my-policy
'Elasticsearch' 카테고리의 다른 글
Elasticsearch 데이터 CRUD (0) | 2021.08.29 |
---|---|
Elasticsearch의 reindex (0) | 2021.08.28 |
Elasticsearch의 Index template 설정하기 (0) | 2021.08.24 |
Kibana 윈도우10에 설치하기 (0) | 2021.08.16 |
Elasticsearch 윈도우10에 설치하기 (0) | 2021.08.16 |