'2017/08'에 해당되는 글 3건

  1. 2017.08.17 [Logstash] input file start_position => "end"
  2. 2017.08.03 [Elasticsearch] Snapshot and Restore 알아보기
  3. 2017.08.02 [Tensorflow] tensorflow source build & install on osx 10.12

[Logstash] input file start_position => "end"

Elastic/Logstash 2017. 8. 17. 11:20

먼저 앞서 기술한 input file 에 대한 내용을 먼저 읽어 보시면 이해 하시는데 도움이 됩니다.


※ [Logstash] input file plugin 에 대해서 알아 봅니다.


이전 글은 데이터 유실 방지를 위한 설정과 input file 의 주요 설정 정보에 대해서 알아 봤습니다.

이번 글에서는 반대로 start_position => "end" 로 했을 때 왜 데이터가 유실 되는지 간략하게 살펴 보겠습니다.


설정)

input {

  file {

    path => "/xxxx/logs/test-file.log"

    start_position => "end"

    stat_interval => 1

  }


  file {

    path => "/xxxx/logs/test-file1.log"

    start_position => "end"

    stat_interval => 10

  }

}


output {

    stdout {

      codec => "rubydebug"

    }

}


첫 번째 실행)

$ bin/logstash -f config/test-file.conf


첫번째 실행 후 sincedb)

189766986 1 4 3675


두 번째 실행)

$ bin/logstash -f config/test-file.conf


두번째 실행 후 sincedb)

189766986 1 4 4065


보시는 것 처럼 start_position => "end"로 했을 경우 해당 파일의 end byte offset 정보를 기록하게 됩니다.

이후 sincedb  정보는 변경이 되지 않게 됩니다.

logstash 를 중지 하고 재실행 합니다.

그 동안 test-file.log 에는 계속 데이터가 누적 되도록 하였습니다.

두 번째 실행 된 후 sincedb 값을 확인해 보면 변경 되어 있는 것을 볼 수 있습니다.


이와 같이 첫 번째 offset 정보와 두 번째 offset 정보의 차이 만큼 데이터가 유실 되게 되는 것입니다.


:

[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은 추천 하지 않지만, 아직 필요한 경우를 찾지는 못했습니다.


:

[Tensorflow] tensorflow source build & install on osx 10.12

ITWeb/개발일반 2017. 8. 2. 09:54

설치 하면서 참고 문서니 순서를 정리 하지 않아서 그냥 raw data 만 일단 투척해 봅니다.

그냥 brew install 해서 설치를 해도 되지만 아래와 같은 오류가 발생을 해서 소스 빌드 했습니다.


[오류]

$ python helloworld.py

2017-08-01 17:04:11.721245: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.

2017-08-01 17:04:11.721266: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.

2017-08-01 17:04:11.721270: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.

2017-08-01 17:04:11.721274: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.

Hello, TensorFlow!

(tensorflow) imac-2:src henry$ deactivate


[참고문서들]


tensorflow)


bazel)


nvidia)

- cudnn 다운로드를 받기 위해서는 로그인을 하셔야 합니다.


기본 설치 가이드)


$ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

$ sudo pip install /tmp/tensorflow_pkg/tensorflow-1.2.1-py2-none-any.whl


# 아래는 six-1.4.1 패키지로 인해서 설치 오류가 발생을 합니다. 이를 회피 하기 위한 옵션 추가 입니다.

$ sudo pip install --ignore-installed six


#!/usr/bin/python

import tensorflow as tf

hello = tf.constant('Hello, TensorFlow!')

sess = tf.Session()

print(sess.run(hello))


: