Elasticsearch 서버는 인덱스로 인해 서버 디스크 용량을 주기적으로 비워줘야한다.
세상은 그리 쉽지 않단다 아가야.
Elasticsearch 서버에서 오래된 인덱스를 백업하여 Cold Data로 활용하는 것이 목표.
- Cold Data를 볼 수 있는 별도 ELK 서버를 구축
- 해당 서버에 백업한 인덱스를 복원
path.repo: "<백업 경로>"
를 입력한 후
sudo systemctl restart elasticsearch 진행
PUT _snapshot/<스냅샷 레포지토리 이름>verify=false
{
"type": "fs",
"settings": {
"location": "<백업 경로>"
}
}
---------
// 예시
PUT _snapshot/backup-test?verify=false
{
"type": "fs",
"settings": {
"location": "/usr/share/elasticsearch/backup-test"
}
}
PUT _snapshot/<스냅샷 레포지토리 이름>/<스냅샷 이름>?wait_for_completion=true
{
"ignore_unavailable": true,
"indices": "<백업할 인덱스>",
"include_global_state": false
}
------------------
// 예시
PUT _snapshot/backup-test/my-index-backupwait_for_completion=true
{
"ignore_unavailable": true,
"indices": "my-index",
"include_global_state": false
}
// 다중 인덱스 백업
PUT _snapshot/backup-test/multi-index-backup?wait_for_completion=true
{
"ignore_unavailable": true,
"indices": "my-index, your-index, her-index",
"include_global_state": false
}
GET _snapshot/<스냅샷 레포지토리 이름>/<스냅샷 이름>
tar -czvf <압축파일명> -C <백업폴더 경로>
# 예시
tar -czvf /home/me/backup.tar.gz -C /usr/share/elasticsearch backup-test
scp backup.tar.gz <USER>@<복원용 ES서버 HOST>:<복원용 ES 서버 경로>
# 예시
scp backup.tar.gz me@10.0.0.0:/home/me
path.repo: "<백업 경로>"
를 입력한 후
sudo systemctl restart elasticsearch 진행
tar xzvf backup.tar -C /usr/share/elasticsearch/
PUT _snapshot/<스냅샷 레포지토리 이름>verify=false
{
"type": "fs",
"settings": {
"location": "<백업 경로>"
}
}
POST _snapshot/<스냅샷 레포지토리 이름>/<백업 시 사용한 스냅샷 이름>/_restore
{
"indices": "<백업 시 기재한 인덱스 명>",
"ignore_unavailable": true,
"include_global_state": false
}
GET _cat/recovery?v&active_only=true
GET _cat/indices?v
# 단일노드이므로 복제본 할당 제거
PUT _all/_settings
{
"index": {
"number_of_replicas": 0
}
}