Elastic Search 03 Shard

junkyu lee·2022년 5월 12일
0

elastic_stack

목록 보기
3/7

https://esbook.kimjmin.net/03-cluster/3.2-index-and-shards


shard

  • Document : 단일 데이터 단위

  • Index : document의 집합

    Shard : 인덱스 단위

  • shard는 저장될 때, 하나의 복사본을 클러스터안의 다른 노드에 저장한다
    - (Primary shard, Replica)(노드가 하나의 경우는 복사본 생성 x)

  • 노드가 유실될 경우

프라이머리 샤드가 유실될 경우 복사본을 프라이머리로 승격 후 복사본 생성

샤드 개수 설정

  • 샤드 5개 복사본 1개인 인덱스 books 생성
$ curl -XPUT "http://localhost:9200/books" -H 'Content-Type: application/json' -d'
{
  "settings": {
    "number_of_shards": 5,
    "number_of_replicas": 1
  }
}'

  • CA 보안 문제 : 일시적인 해결 -k 옵션으로 보안 무시 설정, http -> https로 변경

시도1

curl -XPUT -k  "https://localhost:9200/books" -H 'Content-Type: application/json' -d'
{
	"settings": {
		"number_of_shards": 5,
		"number_of_replicas": 1
	}
}' 

  • 권한 토큰 문제 : 권한이 있는 사용자의 username, password필요

시도2

  • 사용자 비밀번호 변경
$ bin/elasticsearch-setup-passwords  interactive 

  • -u username:password 추가하여 진행
$ curl -XPUT -k -u elastic:123456 "https://localhost:9200/books" -H 'Content-Type: application/json' -d'  
{
        "settings": {
                "number_of_shards": 5,
                "number_of_replicas": 1
        }
}'
  • 결과

예시)

  • books 인덱스 : 샤드 5개, 복제본 1개
  • magazines 인덱스 : 프라이머리 샤드 3개 복제본 0개

profile
가끔 기록하는 velog

0개의 댓글