[Elasticsearch] 싱글노드에서 멀티노드구성으로
Q) 노드는 몇개이상으로 분산시켜야하는가
A) 사용환경에 따라 다르나 장애 처리를 위하여 3개 이상으로 구축해야한다.
만약 노드가 2개라면
Master data(master)
Master node가 죽고 data노드가 master노드로 승격될 경우 데이터 노드가 없어짐
Master data data
Master가 죽을 시 master data 구조로 데이터를 받을 수 있움
Data 노드 죽을시 master data구조로 데이터 받을 수 있음
Q) primary shard 한개로 구동중이라면
A) 프라이머리 샤드 개수를 늘리려면 인덱스를 재생성하는 방법밖에 없다. 레플리카 샤드는 무한정으로 늘릴 수 있다.
인덱스 템플릿 수정 -> 매핑 -> Reindex
샤드가 1개일 경우 앞으로 데이터가 쌓일 인덱스라면 샤드 3개 이상으로 reindex 한다. 데이터가 앞으로 쌓이지 않는 인덱스라면 레플리카로 할당한다
Q)노드수별 적절한 샤드할당은 어떻게 되는가
A)프라이머리샤드 1개당 20G~40G 정도의 샤드를 권장하고 있다.
shard increase or reduce
metricbeat.yml - number of shard 수를 수정해도 반영이 안된다.
legacy index templates
create index templates
기존 템플릿에서
index setting
number_of_shard -> 수정
put metricbeat-7.14.1-2021.09.14 <- 인덱스 생성
#인덱스 템플릿 매핑
post _aliases
{
"actions":[
{
"add": {
"index": "metricbeat-7.14.1-2021.09.10-000001",
"alias": "metricbeat-7.14.1"
}
}]
}
get metricbeat-7.14.1-2021.09.14 <- 생성된 인덱스 보기
(1) 기존 생성된 인덱스도 설정을 바꿔야할 때
wait_for_competion=false -> timeout없이 재색인하는 옵션 (task = 실행중인지 확인)
# post _reindex?wait_for_completion=false
{
"source": {
"index": "metricbeat-7.14.1-2021.09.10-000001"
},
"dest": {
"index": "metricbeat-7.14.1"
}
}
"task" = "qwsdmdqweklcdnmaqnk"
get /_tasks/<task_id>
{
"completed" : false,
"task" : {
"node" : "qqz20VZjThSiQkQ9hSsXRA",
"id" : 9725631,
"type" : "transport",
"action" : "indices:data/write/reindex",
"status" : {
"total" : 3377170,
"updated" : 0,
"created" : 1361000,
"deleted" : 0,
"batches" : 1362,
"version_conflicts" : 0,
"noops" : 0,
"retries" : {
"bulk" : 0,
"search" : 0
},
"throttled_millis" : 0,
"requests_per_second" : -1.0,
"throttled_until_millis" : 0
},
"description" : "reindex from [metricbeat-7.14.1-2021.09.10-000001] to [metricbeat-7.14.1-2021.09.10][_doc]",
"start_time_in_millis" : 1631593025885,
"running_time_in_nanos" : 76986169575,
"cancellable" : true,
"cancelled" : false,
"headers" : { }
}
}
{
"completed" : true,
"task" : {
"node" : "qqz20VZjThSiQkQ9hSsXRA",
"id" : 9725631,
"type" : "transport",
"action" : "indices:data/write/reindex",
"status" : {
"total" : 3377170,
"updated" : 0,
"created" : 3377170,
"deleted" : 0,
"batches" : 3378,
"version_conflicts" : 0,
"noops" : 0,
"retries" : {
"bulk" : 0,
"search" : 0
},
"throttled_millis" : 0,
"requests_per_second" : -1.0,
"throttled_until_millis" : 0
},
"description" : "reindex from [metricbeat-7.14.1-2021.09.10-000001] to [metricbeat-7.14.1-2021.09.10][_doc]",
"start_time_in_millis" : 1631593025885,
"running_time_in_nanos" : 209750695261,
"cancellable" : true,
"cancelled" : false,
"headers" : { }
},
"response" : {
"took" : 209750,
"timed_out" : false,
"total" : 3377170,
"updated" : 0,
"created" : 3377170,
"deleted" : 0,
"batches" : 3378,
"version_conflicts" : 0,
"noops" : 0,
"retries" : {
"bulk" : 0,
"search" : 0
},
"throttled" : "0s",
"throttled_millis" : 0,
"requests_per_second" : -1.0,
"throttled_until" : "0s",
"throttled_until_millis" : 0,
"failures" : [ ]
}
}
completed : true -> 완료
(2) 앞으로 생성될 인덱스의 설정 바꿀 때
post _aliases
{
"actions":[
{
"add": {
"index": "metricbeat-7.14.1-2021.09.10-000001",
"alias": "metricbeat-7.14.1",
"is_write_index": false
}
}]
}
write_index -> 쓰기 허용
post _aliases
{
"actions":[
{
"add": {
"index": "metricbeat-7.14.1-2021.09.14",
"alias": "metricbeat-7.14.1",
"is_write_index": true
}
}]
}