Elasticsearch 노드를 중지 / 종료하는 방법은 무엇입니까?
새 구성으로 elasticsearch 노드를 다시 시작하고 싶습니다. 노드를 정상적으로 종료하는 가장 좋은 방법은 무엇입니까?
프로세스를 종료하는 것이 서버를 종료하는 가장 좋은 방법입니까, 아니면 노드를 종료하는 데 사용할 수있는 매직 URL이 있습니까?
답변이 업데이트되었습니다.
_shutdown
elasticsearch 2.x에서 API가 제거되었습니다.
몇 가지 옵션 :
터미널 (기본적으로 개발 모드)에서 "Ctrl-C"를 입력하십시오.
데몬으로 시작한 경우 (
-d
) PID를 찾아 프로세스SIGTERM
를 종료합니다. Elasticsearch가 완전히 종료됩니다 (kill -15 PID
).서비스로 실행하는 경우 다음과 같이 실행하십시오
service elasticsearch stop
.
이전 답변. 이제 1.6에서 더 이상 사용되지 않습니다.
네. 관리자 클러스터 노드 종료 설명서를 참조하십시오.
원래:
# Shutdown local node
$ curl -XPOST 'http://localhost:9200/_cluster/nodes/_local/_shutdown'
# Shutdown all nodes in the cluster
$ curl -XPOST 'http://localhost:9200/_shutdown'
새 구성을 적용하려는 경우 종료 할 필요가 없습니다.
$ sudo service elasticsearch restart
하지만 어쨌든 종료하려면 :
$ sudo service elasticsearch stop
또는
$ sudo systemctl stop elasticsearch.service
$ sudo systemctl restart elasticsearch.service
Docker :
docker restart <elasticsearch-container-name or id>
이것은 OSX에서 나를 위해 작동합니다.
pkill -f elasticsearch
Elasticsearch 용 Head 플러그인은 노드 종료를 포함하여 Elasticsearch 관리를위한 훌륭한 웹 기반 프런트 엔드를 제공합니다. 모든 Elasticsearch 명령도 실행할 수 있습니다.
서비스를 중지하고 데몬을 종료하는 것은 실제로 노드를 종료하는 올바른 방법입니다. 그러나 유지 관리를 위해 노드를 중단하려는 경우 직접 수행하지 않는 것이 좋습니다. 실제로 복제본이 없으면 데이터가 손실됩니다.
노드를 직접 종료하면 Elasticsearch는 온라인 상태가 될 때까지 1 분 (기본 시간)을 기다립니다. 그렇지 않은 경우 해당 노드의 샤드를 많은 IO를 낭비하는 다른 노드에 할당하기 시작합니다.
일반적인 접근 방식은 다음을 실행하여 일시적으로 샤드 할당을 비활성화하는 것입니다.
PUT _cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": "none"
}
}
이제 노드를 중단 할 때 ES는 해당 노드의 샤드를 다른 노드로 할당하려고 시도하지 않으며 유지 관리 작업을 수행 할 수 있으며 노드가 가동되면 샤드 할당을 다시 활성화 할 수 있습니다.
PUT _cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": "all"
}
}
출처 : https://www.elastic.co/guide/en/elasticsearch/reference/5.5/restart-upgrade.html
모든 인덱스에 대한 복제본이없는 경우 이러한 유형의 활동을 수행하면 일부 인덱스에서 다운 타임이 발생합니다. 이 경우 더 깨끗한 방법은 노드를 중단하기 전에 모든 샤드를 다른 노드로 마이그레이션하는 것입니다.
PUT _cluster/settings
{
"transient" : {
"cluster.routing.allocation.exclude._ip" : "10.0.0.1"
}
}
이렇게하면 모든 샤드 10.0.0.1
가 다른 노드 로 이동합니다 (데이터에 따라 시간이 소요됨). 모든 작업이 완료되면 노드를 종료하고 유지 관리를 수행 한 다음 다시 온라인 상태로 만들 수 있습니다. 이는 더 느린 작업이며 복제본이있는 경우에는 필요하지 않습니다.
(와일드 카드가있는 _ip, _id, _name 대신 잘 작동합니다.)
추가 정보 : https://www.elastic.co/guide/en/elasticsearch/reference/5.5/allocation-filtering.html
다른 답변은 프로세스를 종료하는 방법을 설명했습니다.
다음 명령을 사용하여 이미 실행중인 노드의 pid를 확인하십시오.
curl -XGET ' http : // localhost : 9200 / _nodes / process '
노드를 죽이는 방법을 찾는 데 한 시간이 걸렸고 터미널 창에서이 명령을 사용한 후 마침내 할 수있었습니다.
Windows 컴퓨터에서 elasticsearch를 실행중인 프로세스를 찾을 수없는 경우 콘솔에서 실행 해 볼 수 있습니다.
netstat -a -n -o
elasticsearch가 실행중인 포트를 찾으십시오 9200
. 기본값은 . 마지막 열은 해당 포트를 사용하는 프로세스의 PID입니다. 콘솔에서 간단한 명령으로 종료 할 수 있습니다.
taskkill /PID here_goes_PID /F
인스턴스의 PID를 찾고 프로세스를 종료하려는 경우 노드가 포트 9300 (기본 포트)을 수신하고 있다고 가정하면 다음 명령을 실행할 수 있습니다.
kill -9 $(netstat -nlpt | grep 9200 | cut -d ' ' -f 58 | cut -d '/' -f 1)
58과 1과 같이 위에서 언급 한 코드의 숫자를 가지고 놀아야 할 수도 있습니다.
Docker 내부의 Elasticsearch에 대한 답변 :
Docker 컨테이너를 중지하십시오. 다음을 기록하기 때문에 정상적으로 중지 된 것 같습니다.
[INFO ][o.e.n.Node ] [elastic] stopping ...
로컬 호스트에서 노드를 실행하는 경우 "brew service stop elasticsearch"를 사용하십시오.
iOS localhost에서 elasticsearch를 실행합니다.
3 개의 노드가 있다고 가정합니다.
클러스터 준비
export ES_HOST=localhost:9200
# Disable shard allocation
curl -X PUT "$ES_HOST/_cluster/settings" -H 'Content-Type: application/json' -d'
{
"persistent": {
"cluster.routing.allocation.enable": "none"
}
}
'
# Stop non-essential indexing and perform a synced flush
curl -X POST "$ES_HOST/_flush/synced"
Stop elasticsearch service in each node
# check nodes
export ES_HOST=localhost:9200
curl -X GET "$ES_HOST/_cat/nodes"
# node 1
systemctl stop elasticsearch.service
# node 2
systemctl stop elasticsearch.service
# node 3
systemctl stop elasticsearch.service
Restarting cluster again
# start
systemctl start elasticsearch.service
# Reenable shard allocation once the node has joined the cluster
curl -X PUT "$ES_HOST/_cluster/settings" -H 'Content-Type: application/json' -d'
{
"persistent": {
"cluster.routing.allocation.enable": null
}
}
'
Tested on Elasticseach 6.5
Source:
- https://www.elastic.co/guide/en/elasticsearch/reference/6.5/stopping-elasticsearch.html
- https://www.elastic.co/guide/en/elasticsearch/reference/6.5/rolling-upgrades.html
참고URL : https://stackoverflow.com/questions/17191539/how-to-stop-shut-down-an-elasticsearch-node
'Development Tip' 카테고리의 다른 글
Mercurial (hg)의 저장소에있는 모든 파일을 나열하는 방법은 무엇입니까? (0) | 2020.10.23 |
---|---|
잡히지 않은 RangeError : 경계를 설정하려고 할 때 최대 호출 스택 크기가 Google지도를 초과했습니다. (0) | 2020.10.23 |
arm64와 armhf의 차이점은 무엇입니까? (0) | 2020.10.23 |
grep에서 별표 기호 사용 (0) | 2020.10.23 |
레일 명명 규칙을 어떻게 재정의합니까? (0) | 2020.10.23 |