'Snapshot'에 해당되는 글 4건

  1. 2020.03.16 [AWS] EC2 인스턴스 백업 하기
  2. 2017.08.03 [Elasticsearch] Snapshot and Restore 알아보기
  3. 2014.01.22 [elasticsearch] curator, snapshot & restore 소개.
  4. 2013.04.17 [elasticsearch] Indices API - Snapshot

[AWS] EC2 인스턴스 백업 하기

Cloud&Container/AWS 2020. 3. 16. 17:03

내부에서 사용하는 EC2 인스턴스의 경우 HA 구성까지는 너무 오버라고 생각될 때 최소한의 Backup 정책 정도는 만들어 놓는게 좋습니다.

 

Case 1) 임의 수동 Snapshot 생성

Backup 하고자 하는 Instance 에서 우클릭 후 Snapshot 생성 을 선택 하시면 됩니다.

Selected Instance -> Right Click -> Image -> Create Image

이와 같이 하면 IMAGES 매뉴에서 AMIs  에 생성된 이미지를 보실 수 있습니다.

 

Case 2) 주기적인 자동 Snapshot 생성 (EBS)

EC2 화면에서 수명 주기 관리자(Lifecycle Manager)

Create Snapshot Lifecycle Policy 를 선택해서 필요한 Scheduler 를 만듭니다.

자세한 내용이 궁금한 분들은 공홈 문서를 보시면 좋을 것 같습니다.

https://docs.aws.amazon.com/ko_kr/AWSEC2/latest/UserGuide/ec2-instance-lifecycle.html

https://docs.aws.amazon.com/ko_kr/AWSEC2/latest/UserGuide/ebs-creating-snapshot.html

:

[Elasticsearch] Snapshot and Restore 알아보기

Elastic/Elasticsearch 2017. 8. 3. 11:23

Elasticsearch 에서 제공하는 Snapshot과 Restore 기능에 대해서 정리합니다.


Snapshot과 Restore 기능에 대한 정의와 설명은 아래 본문에 잘 나와 있습니다.


[원본 문서]

https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html

https://www.elastic.co/guide/en/elasticsearch/guide/current/backing-up-your-cluster.html


※ 각 API의 상세 옵션과 설명은 원본 문서 참고 하시면 됩니다.


[발췌]

The snapshot and restore module allows to create snapshots of individual indices or an entire cluster into a remote repository like shared file system, S3, or HDFS. These snapshots are great for backups because they can be restored relatively quickly but they are not archival because they can only be restored to versions of Elasticsearch that can read the index. That means that:


  • A snapshot of an index created in 2.x can be restored to 5.x.
  • A snapshot of an index created in 1.x can be restored to 2.x.
  • A snapshot of an index created in 1.x can not be restored to 5.x.

글에서도 보시는 것 처럼 snapshot type 은 아래와 같이 지원 합니다.
  • fs
  • s3
  • hdfs
  • gcs

각 type을 지정하고 사용하기 위해서는 아래와 같은 추가 작업이 필요 합니다.


fs)

클러스터 내 모든 노드에 path.repo 설정 후 재시작 합니다.

- elasticsearch.yml

반드시 shared file system 적용을 해주셔야 합니다. 


s3)

클러스터 내 모든 노드에 plugin 설치를 해주셔야 합니다.

aws의 s3를 사용하기 위해서는 repository plugin 을 설치해야 합니다.


2.x)

bin/plugin install cloud-aws


5.x)

bin/elasticsearch-pluin install repository-s3


hdfs)

https://github.com/elastic/elasticsearch-hadoop/tree/master/repository-hdfs


클러스터 내 모든 노드에 plugin 설치를 해주셔야 합니다.

hadoop file system을 사용하기 위해서는 repository plugin 을 설치해야 합니다.


2.x)

bin/plugin install elasticsearch-repository-hdfs


5.x)

bin/elasticsearch-pluin install repository-hdfs


gcs)

클러스터 내 모든 노드에 plugin 설치를 해주셔야 합니다.

google cloud storage를 사용하기 위해서는 repository plugin 을 설치해야 합니다.


5.x)

bin/elasticsearch-pluin install repository-gcs


azure)

https://github.com/elastic/elasticsearch-cloud-azure


클러스터 내 모든 노드에 plugin 설치를 해주셔야 합니다.

azure repository를 사용하기 위해서는 repository plugin 을 설치해야 합니다.


2.x)

bin/plugin install elasticsearch/elasticsearch-cloud-azure


5.x)

bin/elasticsearch-pluin install repository-azure


이 중 2.X 클러스터에서 제가 추천 하는 것은 fs, s3 입니다.

이유는 다른건 제가 경험이 없어서 좋은지 나쁜지는 모릅니다.


fs, s3 에 대한 예제를 가지고 snapshot 과정과 restore 과정을 살펴 보겠습니다.


[fs]

step 1)

snapshot 기능을 수행 하기 위한 snapshot 저장소를 생성 합니다.


$ curl -XPUT 'localhost:9200/_snapshot/fs_snapshot?pretty' -d '{

    "type": "fs",

    "settings": {

        "location": "/mount/snapshot",

        "compress": true

    }

}'


step 2)

snapshot 할 대상을 선정하고 실행 합니다.


$ curl -XPUT 'localhost:9200/_snapshot/fs_snapshot/logstash_20170803?pretty' -d '

{

  "indices": "logstash-web-20170803,logstash-app-20170803",

  "ignore_unavailable": true,

  "include_global_state": false

}'


step 3)

이제 restore 해보겠습니다.


$ curl -XPOST 'localhost:9200/_snapshot/fs_snapshot/logstash_20170803/_restore'


[s3]

step 1)

snapshot 기능을 수행 하기 위한 snapshot 저장소를 생성 합니다.


$ curl -XPUT 'localhost:9200/_snapshot/s3_snapshot?pretty' -d '{

    "type": "s3",

    "settings": {

        "bucket": "s3-bucket",

        "region": "ap-northeast-2"

    }

}'


step 2)

snapshot 할 대상을 선정하고 실행 합니다.


$ curl -XPUT 'localhost:9200/_snapshot/s3_snapshot/logstash_20170803?pretty' -d '

{

  "indices": "logstash-web-20170803,logstash-app-20170803",

  "ignore_unavailable": true,

  "include_global_state": false

}'


step 3)

이제 restore 해보겠습니다.


$ curl -XPOST 'localhost:9200/_snapshot/s3_snapshot/logstash_20170803/_restore'


하나의 클러스터 내 여러개의 snapshot repository 를 등록해서 사용 하셔도 되기 때문에 목적에 맞게 사용 하시면 좋을 것 같습니다.


이 과정들은 모두 background 로 동작 하기 때문에 실행 후 바로 acknowledged/accepted 가 전달 됩니다.

그렇기 때문에 실행한 snapshot 의 상태 점검을 하셔야 합니다.


$ curl -XGET 'localhost:9200/_snapshot/s3_snapshot/logstash_20170803/_status'


추가적으로 사용하시면서 약간의 주의점 공유 드립니다.

- 더이상 색인 작업이 발생 하지 않는 index 들에 대해서 snapshot 작업을 수행하시면 좋습니다.

- restore 시는 대상 index 가 없거나 close 되어 있어야 하기 때문에 지속적인 색인 작업이 발생 하는 index에 대한 snapshot은 추천 하지 않지만, 아직 필요한 경우를 찾지는 못했습니다.


:

[elasticsearch] curator, snapshot & restore 소개.

Elastic/Elasticsearch 2014. 1. 22. 10:42

그냥 elasticsearch.org 블로그 들어가 보시면 있는 내용입니다.

관심 있는 분들은 벌써 아실 내용이긴 한데 그냥 소개해 봅니다.



이건 원래도 있던 기능이긴 했는데 그닥 유용하다고 생각 하지 않았습니다.

이번에 나온건 실제 유용하게 사용할 수 있겠더라구요.

일단 지원 하는 repository 를 보면.


Currently, we support file system, S3, Azure and HDFS repositories.


백업 및 복구용으로 활용하세요.




간단하게 소개 하면 index 에 대한 disk 용량 관리를 해주는 도구라고 보시면 됩니다.

아마도 logstash 를 사용하시는 분들에게 필요한 도구 일 것 같구요.

cron 에 등록해 놓고 사용 하시면 됩니다.


[옵션]

$ curator.py -h
usage
: curator.py [-h] [-v] [--host HOST] [--port PORT] [-t TIMEOUT]
                 
[-p PREFIX] [-s SEPARATOR] [-C CURATION_STYLE]
                 
[-T TIME_UNIT] [-d DELETE_OLDER] [-c CLOSE_OLDER]
                 
[-b BLOOM_OLDER] [-g DISK_SPACE]
                 
[--max_num_segments MAX_NUM_SEGMENTS] [-o OPTIMIZE] [-n]
                 
[-D] [-l LOG_FILE]

Curator for Elasticsearch indices. Can delete (by space or time), close,
disable bloom filters and optimize
(forceMerge) your indices.

optional arguments
:
 
-h, --help            show this help message and exit
 
-v, --version         show program version number and exit
 
--host HOST           Elasticsearch host. Default: localhost
 
--port PORT           Elasticsearch port. Default: 9200
 
-t TIMEOUT, --timeout TIMEOUT
                       
Elasticsearch timeout. Default: 30
 
-p PREFIX, --prefix PREFIX
                       
Prefix for the indices. Indices that do not have this
                        prefix are skipped
. Default: logstash-
 
-s SEPARATOR, --separator SEPARATOR
                       
Time unit separator. Default: .
 
-C CURATION_STYLE, --curation-style CURATION_STYLE
                       
Curate indices by [time, space] Default: time
 
-T TIME_UNIT, --time-unit TIME_UNIT
                       
Unit of time to reckon by: [days, hours] Default: days
 
-d DELETE_OLDER, --delete DELETE_OLDER
                       
Delete indices older than n TIME_UNITs.
 
-c CLOSE_OLDER, --close CLOSE_OLDER
                       
Close indices older than n TIME_UNITs.
 
-b BLOOM_OLDER, --bloom BLOOM_OLDER
                       
Disable bloom filter for indices older than n
                        TIME_UNITs
.
 
-g DISK_SPACE, --disk-space DISK_SPACE
                       
Delete indices beyond n GIGABYTES.
 
--max_num_segments MAX_NUM_SEGMENTS
                       
Maximum number of segments, post-optimize. Default: 2
 
-o OPTIMIZE, --optimize OPTIMIZE
                       
Optimize (Lucene forceMerge) indices older than n
                        TIME_UNITs
. Must increase timeout to stay connected
                        throughout optimize operation
, recommend no less than
                       
3600.
 
-n, --dry-run         If true, does not perform any changes to the
                       
Elasticsearch indices.
 
-D, --debug           Debug mode
 
-l LOG_FILE, --logfile LOG_FILE
                        log file


:

[elasticsearch] Indices API - Snapshot

Elastic/Elasticsearch 2013. 4. 17. 14:40

본 문서는 개인적인 테스트와 elasticsearch.org 그리고 community 등을 참고해서 작성된 것이며,

정보 교환이 목적입니다.


잘못된 부분에 대해서는 지적 부탁 드립니다.

(예시 코드는 성능 및 보안 검증이 되지 않았습니다.)



[elasticsearch API 리뷰]

원문 링크 : http://www.elasticsearch.org/guide/reference/api/admin-indices-gateway-snapshot/


이 API 는 shared storage gateway 에서 동작 합니다.

local storage gateway 에서는 필요 하지 않다는 점을 유의 하시기 바랍니다.


- snapshot 정보는 shared storage location 에 저장 됩니다.


아래는 간단한 Java Code 예제 입니다.


[Java 예제]

request.indices("blog")

.operationThreading(BroadcastOperationThreading.THREAD_PER_SHARD);


response = indices.gatewaySnapshot(request).actionGet();


log.debug("{}", response.getSuccessfulShards());

: