elasticsearch query cache 세팅을 바꿔줘야한다고 해서 이것저것 찾아봤는데 움...이렇게 해도 되나 싶어서 일단 정리만 해봤다. 테스트 진행해보고 수정해줄 부분은 수정해줄 예정이다. 일단 query cache 를 바꿔서 테스트해봤으면 한다는 의견에 따라 찾아봤는데 cache는 elasticsearch.yml 을 변경해야해야했다. 그리고 elasticsearch를 restart해줘야했다. restart를 해주면 모든 노드들이 내렸갔다가 올라가야하는데, 이슈가 생기지 않을까 걱정이 됐다. 이는 두 가지 방법이 있었다.
filter query
에 대한 응답속도를 개선하기 위한 캐시작업query
나 aggreagation
은 해당 캐시가 적용되지 않음elasticsearch.yml
에 index.queries.cache.enabled
과 indices.queries.cache.size
이 추가나 수정이 필요함index.queries.cache.enabled
: 인덱스별로 캐시를 사용할 것인지 세팅이 가능함 인덱스를 생성할때나 닫힌 인덱스에서만 세팅이 가능 (default값이 true)index.queries.cache.size
: JVM Heap의 캐시 공간을 얼마나 사용할지 설정(default값이 10%)index.queries.cache.enabled: true 또는 false
indices.queries.cache.size: 10% 또는 5mb
PUT _cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": "primaries"
}
}
(2) 인덱스 flush(즉, 인덱스 새로고침)POST /_flush
(3) 노드 셧다운(full cluster의 경우에는 모든 노드 셧다운/ rolling의 경우에는 싱글 노드 셧다운)/etc/init.d/elasticsearch stop
// 모든 노드를 한꺼번에 stop하는 커맨드와 싱글 노드를 stop하는 커맨드를 어떻게 다르게 쓰는거지?
(4) 수정할 부분 수정/etc/init.d/elasticsearch start
// 모든 노드를 한꺼번에 start하는 커맨드와 싱글 노드를 stop하는 커맨드를 어떻게 다르게 쓰는거지?
*재시작하면서 아래 명령어로 모니터링하면서 진행하는 것이 좋음GET _cat/health
GET _cat/nodes
(6) 샤드 재할당 원복PUT _cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": "null"
}
}
*진행시 아래 명령어로 모니터링GET _cat/health
GET _cat/recovery
참고 : https://www.elastic.co/guide/en/elasticsearch/reference/current/query-cache.html
https://velog.io/@mayhan/Elasticsearch-Cache
https://www.elastic.co/guide/en/elasticsearch/reference/current/restart-cluster.html#restart-cluster-full