* documentation을 참고함 (v7.10)
Elasticsearch란?
Elasticsearch는 분산형 검색 분석 엔진으로 Elastic Stack의 중심이다.
Logstash와 Beat는 데이터를 수집, 집계 하며 Elasticserach에 저장하고, Kibana는 interactively하게 데이터를 탐색하고 시각화하며 stack을 모니터하게 해준다.
즉, Elasticsearch는 인덱싱, 검색, 분석 마법이 일어나는 곳이다 (Elasticsearch is where the indexing, search, and analysis magic happens.)
Data in: documents and indices
Elasticsearch는 분산 문서 저장소 이다.
Elasticsearch는 정보를 열 데이터 행으로 저장하는 대신 JSON 문서로 열거된 복잡한 데이터 구조를 저장한다.
(1) cluster에 많은 Elasticsearch node가 있는 경우 저장된 문서는 클러스터 전체에 분산되고 즉각적으로 모든 노드에서 엑세스 할 수 있다. 문서가 저장될 때, 문서가 색인되고 실시간으로 1초 이내에 전체 검색이 가능하다. (나는 경험상으로는 실시간으로는 불가능 하고 1초보다는 3초 정도 시간이 지나야 검색 가능 했는데... 역색인, 형태소 분석 하는 시간 때문에 그런줄 알고있었는데)
(2) Elasticsearch는 inverted index(역색인)라고 불리는 데이터 구조를 사용하고 굉장히 빠른 전체 텍스트 검색을 지원한다. inverted index는 문서에 나오는 모든 고유 단어를 나열하고 각 단어가 나오는 문서를 식별한다. 기본적으로 Elasticsearch는 모든 데이터를 인덱싱하고 각 인덱싱된 필드는 최적화 된 데이터 구조를 가지고 있다. 예를 들면, 텍스트 필드는 inverted indices에 저장되고 숫자나 지역 필드는 BKD tree에 저장된다.
필드 별 데이터 구조를 사용하여 검색 결과를 조합하고 반환하는 기능은 Elasticsearch를 매우 빠르게 만들어 준다.
(3) Elasticsearch는 schema가 없는 기능도 있다. 따라서 schema를 명시적으로 지정하지 않고도 문서를 인덱싱 할 수 있다. (하지만 보통은 이렇게 사용하면 데이터를 제어하기 힘들지)
Scalability(확장성) and resilience(복원력): clusters, nodes, and shards
Elasticsearch는 데이터와 quary 로드를 사용 가능한 모든 노드에 자동으로 분산해준다.
내부적으로 Elasticsaerch index는 실제로 하나 혹은 그 이상의 shard의 그룹이다. index의 문서를 여러 샤드에 분산하고 해당 shard를 여러 노드에 분산하면 Elasticsearch는 중복성을 보장할 수 있다. 이는 하드웨어 장애로부터 보호하고 node가 cluster에 추가 될 때 쿼리 용량을 증가시킨다. cluster가 증가 하거나 혹은 수축할때, Elasticsearch는 cluster를 재조정 하기 위해 자동으로 shard를 마이그레이션 한다.

shards는 두개의 type이 존재한다: primaries and replicas
- 인덱스의 각 문서는 하나의 primary shard에 속한다. replica shard는 primary shard의 복사본이다.
- replica는 하드웨어 장애와 문서 검색 또는 읽기 요청을 처리하는 capacity 증가에서 보호할 수 있게 해준다.
- 인덱스가 생성될 때 primary shard의 수는 고정되어 있지만, replica shard의 수는 변경 할 수 있다.
shard 크기를 지정할때,
- Aim to keep the average shard size between a few GB and a few tens of GB. For use cases with time-based data, it is common to see shards in the 20GB to 40GB range.
- Avoid the gazillion shards problem. The number of shards a node can hold is proportional to the available heap space. As a general rule, the number of shards per GB of heap space should be less than 20.
성능상의 이유로 cluster안의 node는 같은 네트워크에 있어야 한다.
요약 정리
- node는 우리가 Elasticsearch에 넣은 것을 저장한다.
- cluster는 node의 컬렉션이다.
- data는 Json object 형식인 document로 저장된다.
- document는 indeces와 함께 그룹화 된다.
참고
- www.elastic.co/guide/en/elasticsearch/reference/current/elasticsearch-intro.html
What is Elasticsearch? | Elasticsearch Reference [7.10] | Elastic
What is Elasticsearch?edit You know, for search (and analysis) Elasticsearch is the distributed search and analytics engine at the heart of the Elastic Stack. Logstash and Beats facilitate collecting, aggregating, and enriching your data and storing it in
www.elastic.co
- www.siscale.com/elasticsearch-shard-optimization/
Elasticsearch - shard optimization - Siscale
Elasticsearch shards can be a daunting subject to tackle considering how much of an impact they can have on your cluster. In this article we explain what shards are and how they work and offer some advice on what can be a good practice.
www.siscale.com
'Elastic Stack > Elastic search' 카테고리의 다른 글
2. Set up Elasticsearch (0) | 2020.12.20 |
---|