# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /path/to/data
#
# Path to log files:
#
path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
$ sudo vi etc/security/limits.conf
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited
# {계정명} -> yum or rpm 설치시 디폴트계정명(=elasticsearch)
$ sudo mkdir /etc/systemd/system/elasticsearch.service.d
$ sudo vi /etc/systemd/system/elasticsearch.service.d/override.conf
[service]
LimitMEMLOCK=infinity
$ sudo systemctl deamon-reload
⇒ 위 추가설정 없이 bootstrap.memory_lock: true 설정시 프로세스가 시작되지 않음.
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
#network.host: 192.168.0.1
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
외부와 통신하기 위한 IP & 노드간 통신 설정
network.host : IP주소 설정.
아래 두가지 설정을 한번에 설정하기 위한 필드. 두가지로 나누어 각각 설정 할 수 있다.
대게 분리해서 설정함.
WHY?
⇒ bind_host 를 특정 IP로 지정하면, 노드 내부에서도 localhost(127.0.0.1)으로 접근 할 수 없다.
⇒ 스크립트나 자동화를 통해 ElasticSearch관리시 localhost 사용이 효율적.
⇒ 0.0.0.0 설정 권장 → 노드IP + localhost 모두 사용 가능.
⇒ 하지만, 두개이상의 노드의 경우 같은 IP로 설정시, 통신 불가능...
⇒ [결론] 클라이언트 요청 = 노드IP + localhost & 노드간 통신 = 노드IP (5.3에서 해결방안)
network.bind_host - 노드간 통신
network.publish_host - 외부통신
http.port : 포트 설정
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
⇒ hosts에 설정된 IP에 ElasticSearch 떠있는지 확인 → 해당 클러스터의 정보를 받아서, 마스터 노드 개수를 확인. 최소 개수 이상이면, 성공적으로 클러스터에 합류.
*split brain 현상 :
data node (3개) + master node (3개)
마스터 노드간 통신이 (2) / (1) 로 분리 되었을때, 최소 마스터 노드가 1개 일경우
분리된 두 클러스터 모두 조건을 충족 → 그래서, 과반수인 2로 설정을 하여 이런 경우를 방지.
과반수 : (전체 마스터 후보 노드 / 2) + 1
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
⇒ 노드 역할은 중복 설정이 가능.
ElasticSearch는 자바 기반 → 힙 메모리, GC 같은 JVM 설정이 필요
어플리케이션 성능에 중요!
jvm.options
################################################################
##
## JVM configuration
##
################################################################
##
## WARNING: DO NOT EDIT THIS FILE. If you want to override the
## JVM options in this file, or set any additional options, you
## should create one or more files in the jvm.options.d
## directory containing your adjustments.
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/jvm-options.html
## for more information.
##
################################################################################################################################
## IMPORTANT: JVM heap size
################################################################
##
## The heap size is automatically configured by Elasticsearch
## based on the available memory in your system and the roles
## each node is configured to fulfill. If specifying heap is
## required, it should be done through a file in jvm.options.d,
## and the min and max should be set to the same value. For
## example, to set the heap to 4 GB, create a new file in the
## jvm.options.d directory containing these lines:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################
################################################################
## Expert settings
################################################################
##
## All settings below here are considered expert settings. Do
## not adjust them unless you understand what you are doing. Do
## not edit them in this file; instead, create a new file in the
## jvm.options.d directory containing your adjustments.
##
################################################################
## GC configuration
8-13:-XX:+UseConcMarkSweepGC
8-13:-XX:CMSInitiatingOccupancyFraction=75
8-13:-XX:+UseCMSInitiatingOccupancyOnly
## G1GC Configuration
# NOTE: G1 GC is only supported on JDK version 10 or later
# to use G1GC, uncomment the next two lines and update the version on the
# following three lines to your version of the JDK
# 10-13:-XX:-UseConcMarkSweepGC
# 10-13:-XX:-UseCMSInitiatingOccupancyOnly
14-:-XX:+UseG1GC
## JVM temporary directory
-Djava.io.tmpdir=${ES_TMPDIR}
## heap dumps
# generate a heap dump when an allocation from the Java heap fails; heap dumps
# are created in the working directory of the JVM unless an alternative path is
# specified
-XX:+HeapDumpOnOutOfMemoryError
# specify an alternative path for heap dumps; ensure the directory exists and
# has sufficient space
-XX:HeapDumpPath=data
# specify an alternative path for JVM fatal error logs
-XX:ErrorFile=logs/hs_err_pid%p.log
## JDK 8 GC logging
8:-XX:+PrintGCDetails
8:-XX:+PrintGCDateStamps
8:-XX:+PrintTenuringDistribution
8:-XX:+PrintGCApplicationStoppedTime
8:-Xloggc:logs/gc.log
8:-XX:+UseGCLogFileRotation
8:-XX:NumberOfGCLogFiles=32
8:-XX:GCLogFileSize=64m
# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m
-Xms1g(최소) / -Xmx1g(최대)
최대/최소 힙메모리 크기 설정
두 값이 같지 않으면, 처음에 최소로 확보후 추가 확보를 하게됨 → 성능 저하 → 같은값 설정 권장
권장사항
32GB 넘지 않게 설정할것
JVM의 연산을 위한 데이터를 저장하기 위한 공간 = 힙 메모리
힙 메모리에 저장되는 데이터 = 오브젝트
오브젝트에 접근하기 위한 메모리상의 주소 = OOP(Ordinary Object Pointer) → 구조체
OOP는 시스템 아키텍처에 따라 32비트(최대4GB)
or 64비트(최대16GB
) 주소공간을 가리킴
실제 성능 : 32비트 >> 64비트
이유? 더 많은 연산과 더 많은 메모리 공간을 필요로한다.
⇒ 이러한 성능 저하를 방지 하기 위해 Compressed OOP
로 32비트 기반으로도 4GB이상의 영역을 가르키도록 구현
Native OOP VS Compressed OOP
1 → 주소1 → 주소 8
2 → 주소2 → 주소 16
8배 많은 주소 공간 표시 가능
기존 4GB → 32GB까지 증가
전체 메모리의 절반정도로 설정할것
ElasticSearch는 빈번한 I/O발생(=성능) → 페이지 캐시 활용하는 것이 좋음
페이지 캐시
OS에서 I/O발생을 줄이기 위해 메모리에 저장
애플리케이션이 사용하지 않는 미사용 메모리를 활용 → 애플리케이션의 메모리를 줄여야함
8-13:-XX:+UseConcMarkSweepGC
8-13:-XX:CMSInitiatingOccupancyFraction=75
8-13:-XX:+UseCMSInitiatingOccupancyOnly
## G1GC Configuration