Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 2개 있습니다.)

Windows - 단일 머신에서 단일 바이너리로 여러 개의 ElasticSearch 노드를 실행하는 방법

실제 운영 시에는 머신 하나 당 노드 한 개를 유지하겠지만, 테스트 환경을 구축할 때는 그게 좀 번거롭긴 합니다. 따라서 한 대의 머신에서 해결하는 것이 좋은데, 이를 위해 가장 쉬운 방법은, elasticsearch.yml 파일에 node.max_local_storage_nodes 설정을 포함하는 것입니다. (물론, docker를 이용해도 됩니다.)

node.max_local_storage_nodes: 3

그럼, 동일한 경로에 설치된 elasticsearch.bat 파일을 서로 다른 명령행 창에서 3번 실행할 수 있고, 이렇게 확인할 수 있습니다.

C:\temp> curl -XGET "localhost:9200/_cat/health?v&pretty"
epoch      timestamp cluster    status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1598856739 06:52:19  my_cluster green           3         3      0   0    0    0        0             0                  -                100.0%

그런데, 아무리 테스트 환경이라고 해도 기본 설정 상태에서는 "localhost"로만 접근이 되는 제약이 있으므로, 다른 머신에서 접근하기 위해 HTTP 바인딩을 바꾸는 경우,

network.host: _site_

아쉽게도 실행 오류가 발생하며 종료합니다.

...[생략]...
[2020-08-31T11:51:13,039][INFO ][o.e.n.Node               ] [TESTPC] initialized
[2020-08-31T11:51:13,039][INFO ][o.e.n.Node               ] [TESTPC] starting ...
[2020-08-31T11:51:13,844][INFO ][o.e.t.TransportService   ] [TESTPC] publish_address {172.26.48.6:9300}, bound_addresses {172.26.48.6:9300}, {192.168.0.167:9300}
[2020-08-31T11:51:14,489][INFO ][o.e.b.BootstrapChecks    ] [TESTPC] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [1] bootstrap checks failed
[1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
ERROR: Elasticsearch did not exit normally - check the logs at D:\elk\elasticsearch\logs\my_cluster.log
[2020-08-31T11:51:14,513][INFO ][o.e.n.Node               ] [TESTPC] stopping ...
[2020-08-31T11:51:14,536][INFO ][o.e.n.Node               ] [TESTPC] stopped
[2020-08-31T11:51:14,537][INFO ][o.e.n.Node               ] [TESTPC] closing ...
[2020-08-31T11:51:14,576][INFO ][o.e.n.Node               ] [TESTPC] closed
[2020-08-31T11:51:14,579][INFO ][o.e.x.m.p.NativeController] [TESTPC] Native controller process has stopped - no new native processes can be started

이 오류를 수정하려면, discovery.seed_hosts 옵션으로,

Problems with access to Elasticsearch form outside machine
; https://discuss.elastic.co/t/problems-with-access-to-elasticsearch-form-outside-machine/172450/3

빈 값을 넣어도 된다고 하는데,

discovery.seed_hosts: []

실제로 이렇게 설정하고 Elasticsearch 인스턴스를 실행하면 이번엔 종료는 안 되지만 다음과 같은 메시지가 반복되며 출력될 뿐,

[2020-08-31T16:23:44,260][WARN ][o.e.c.c.ClusterFormationFailureHelper] [TESTPC] master not discovered yet, this node has not previously joined a bootstrapped (v7+) cluster, and [cluster.initial_master_nodes] is empty on this node: have discovered [{TESTPC}{g1hWq0_bT7WurIZn9hWLOg}{GcqjG1_AQTyoyiKG32Yaag}{172.26.48.6}{172.26.48.6:9300}{dilmrt}{ml.machine_memory=8588800000, xpack.installed=true, transform.node=true, ml.max_open_jobs=20}]; discovery will continue using [] from hosts providers and [{TESTPC}{g1hWq0_bT7WurIZn9hWLOg}{GcqjG1_AQTyoyiKG32Yaag}{172.26.48.6}{172.26.48.6:9300}{dilmrt}{ml.machine_memory=8588800000, xpack.installed=true, transform.node=true, ml.max_open_jobs=20}] from last-known cluster state; node term 0, last-accepted version 0 in term 0


정상적인 동작은 하지 않습니다. 대신 discovery.seed_hosts에 (127.0.0.1이 아닌) "bound_addresses"로 출력된,

...[생략]...
[2020-08-31T11:51:13,844][INFO ][o.e.t.TransportService   ] [TESTPC] publish_address {172.26.48.6:9300}, bound_addresses {172.26.48.6:9300}, {192.168.0.167:9300}
...[생략]...

IP 주솟값을 줘야 합니다. 위의 출력에서는 "172.26.48.6", "192.168.0.167"이 있으므로 둘 중의 하나를 설정하고,

discovery.seed_hosts: [ "172.26.48.6" ]

이후, 2개 더 Elasticsearch.bat을 실행하는 경우 3개의 노드가 1개의 클러스터에 활성화한 것을 볼 수 있습니다.

c:\temp> curl -XGET "172.26.48.6:9200/_cat/health?v&pretty"
epoch      timestamp cluster    status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1598859586 07:39:46  my_cluster green           3         3      0   0    0    0        0             0                  -                100.0%




향후 실행했을 때, 1개의 노드만 실행하는 경우 다음과 같이 예외가 발생할 수 있습니다.

[2020-08-31T16:58:51,417][WARN ][o.e.c.c.ClusterFormationFailureHelper] [TESTPC] master not discovered or elected yet, an election requires at least 2 nodes with ids from [Y0nYZsd2Q-izMTZQRF49vA, xU_vDh9uS7WDxJqlVqNmQw, abSNuGzETB-ah8M2LjfKKw], have discovered [{TESTPC}{Y0nYZsd2Q-izMTZQRF49vA}{ELdxViPRT8Gb0SmwUpeUEA}{172.26.48.6}{172.26.48.6:9300}{dilmrt}{ml.machine_memory=8588800000, xpack.installed=true, transform.node=true, ml.max_open_jobs=20}] which is not a quorum; discovery will continue using [] from hosts providers and [{TESTPC}{Y0nYZsd2Q-izMTZQRF49vA}{ELdxViPRT8Gb0SmwUpeUEA}{172.26.48.6}{172.26.48.6:9300}{dilmrt}{ml.machine_memory=8588800000, xpack.installed=true, transform.node=true, ml.max_open_jobs=20}] from last-known cluster state; node term 6, last-accepted version 52 in term 6


메시지에도 나오지만, 최소 2개 이상의 노드가 실행되어 있어야 하므로 하나 더 노드를 실행하면 정상적으로 서비스 하게 됩니다.




참고로, Elasticsearch의 바이너리를 설치하자마자 처음부터 yml 설정을 저런 식으로 바꿔서 실행하면 안 됩니다. 그런 경우, 메타 데이터를 생성하지 않은 상태로 서로 마스터로 승격된 것으로부터 동기화를 하려고 시도하므로 모든 노드가 메타 데이터가 없어 정상 동작을 하지 않게 됩니다.

따라서, 처음에는 기본 상태에서 Elasticsearch.bat을 실행해 기본 실행을 위한 Metadata 생성을 한 후 다음의 설정을 추가/구성하는 식으로 진행해야 합니다.

node.max_local_storage_nodes: 3
network.host: _site_
discovery.seed_hosts: [ "172.26.48.6" ]




"network.host"의 경우 공식 문서를 보면,

Elasticsearch Reference [7.9] - Modules - Network Settings
; https://www.elastic.co/guide/en/elasticsearch/reference/7.9/modules-network.html#network-interface-values

"127.0.0.1"을 나타내는 "_local_", 네트워크 어댑터마다 할당된 주소 중 사설 IP 대역을 선택하는 "_site_"와 공용 IP 대역을 선택하는 "_global_"이 있는데, 어떤 것을 선택하든 IPAddress.Any의 의미를 갖진 않습니다. 즉, "_site_"나 "_global_"로 선택한 경우 로컬 PC에서는 간편하게 127.0.0.1로도 접속하고 싶은데 그게 안 됩니다.

그래도 ^^ 괜찮습니다. 그냥 IPAddress.Any의 의미로 "0.0.0.0"을 지정해도 무방합니다.

network.host: 0.0.0.0

그런 경우 discovery.seed_hosts의 값도 IP 주소를 하드코딩하지 않고 127.0.0.1로 지정할 수 있습니다.

discovery.seed_hosts: [ "127.0.0.1" ]




같은 바이너리/yml 설정을 바탕으로 실행되었으므로 node 이름이 다소 멋있지 않은데요, 이 문제는 명령행을 다음과 같이 나눠서 실행하는 것으로 보완할 수 있습니다.

elasticsearch -Enode.name=node-1
elasticsearch -Enode.name=node-2
elasticsearch -Enode.name=node-3

그래서 head 크롬 확장으로 보면 다음과 같은 상태를 확인할 수 있습니다.

es_cluster_1.png




마지막으로 유의해야 할 것은, 공식 문서에도 나오지만,

Node - node.max_local_storage_nodes
; https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-node.html#max-local-storage-nodes

This setting is deprecated in 7.x and will be removed in version 8.0.

이런 식의 테스트는 7.x까지만 가능하고 향후의 8.0부터는 없어진다는 점! 시간이 되시면 아래의 문서도 한 번쯤 읽어보시고. ^^

3.1 클러스터 구성
; https://esbook.kimjmin.net/03-cluster/3.1-cluster-settings




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 9/2/2020]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 16  17  18  19  20  21  22  [23]  24  25  26  27  28  29  30  ...
NoWriterDateCnt.TitleFile(s)
13050정성태5/6/20226471.NET Framework: 2003. C# - COM 개체의 이벤트 핸들러에서 발생하는 예외에 대한 CLR의 특별 대우파일 다운로드1
13049정성태5/6/20225434오류 유형: 811. GoLand - Error: Cannot find package
13048정성태5/6/20226555오류 유형: 810. "ASUS TUF GAMING B550M-PLUS (WI-FI)" 모델에서 블루투스 장치가 인식이 안 되는 문제
13047정성태5/6/20226533오류 유형: 809. Speech Recognition could not start
13046정성태5/5/20226828.NET Framework: 2002. C# XingAPI - ACF 파일을 이용한 퀀트 종목 찾기(t1857)
13045정성태5/5/20226875.NET Framework: 2001. C# XingAPI - 주식 종목에 따른 PBR, PER, ROE 구하는 방법(t3341 예제)
13044정성태5/4/20226336오류 유형: 808. error : clang++ exited with code 127
13043정성태5/3/20225973오류 유형: 807. C# - 닷넷 응용 프로그램에서 Informix DB 사용 시 오류 메시지 정리
13042정성태5/3/20226358.NET Framework: 2000. C# - 닷넷 응용 프로그램에서 Informix DB 사용 방법파일 다운로드1
13041정성태4/28/20226616개발 환경 구성: 642. Informix 데이터베이스 docker 환경 구성
13040정성태4/27/20227141VC++: 156. 비주얼 스튜디오 - Linux C/C++ 프로젝트에서 openssl 링크하는 방법
13039정성태4/27/20227928.NET Framework: 1999. C# - Playwright를 이용한 간단한 브라우저 제어 실습
13038정성태4/26/20225831오류 유형: 806. twine 실행 시 ConfigParser.ParsingError: File contains parsing errors: /root/.pypirc
13037정성태4/25/20226156.NET Framework: 1998. Azure Functions를 사용한 간단한 실습
13036정성태4/24/20226886.NET Framework: 1997. C# - nano 시간을 가져오는 방법 [2]
13035정성태4/22/20227469Windows: 204. Windows 10부터 바뀐 QueryPerformanceFrequency, QueryPerformanceCounter
13034정성태4/21/20226849.NET Framework: 1996. C# XingAPI - 주식 종목에 따른 PBR, PER, ROE, ROA 구하는 방법(t3320, t8430 예제)파일 다운로드1
13033정성태4/18/20227478.NET Framework: 1195. C# - Thread.Yield와 Thread.Sleep(0)의 차이점(?)
13032정성태4/17/20227175오류 유형: 805. Github의 50MB 파일 크기 제한 - warning: GH001: Large files detected. You may want to try Git Large File Storage
13031정성태4/15/20226723.NET Framework: 1194. C# - IdealProcessor와 ProcessorAffinity의 차이점
13030정성태4/15/20226411오류 유형: 804. 정규 표현식 오류 - Quantifier {x,y} following nothing.
13029정성태4/14/20226816Windows: 203. iisreset 후에도 이전에 설정한 전역 환경 변수가 w3wp.exe에 적용되는 문제
13028정성태4/13/20226720.NET Framework: 1193. (appsettings.json처럼) web.config의 Debug/Release에 따른 설정 적용
13027정성태4/12/20227016.NET Framework: 1192. C# - 환경 변수의 변화를 알리는 WM_SETTINGCHANGE Win32 메시지 사용법파일 다운로드1
13026정성태4/11/20228517.NET Framework: 1191. C 언어로 작성된 FFmpeg Examples의 C# 포팅 전체 소스 코드 [3]
13025정성태4/11/20227879.NET Framework: 1190. C# - ffmpeg(FFmpeg.AutoGen)를 이용한 vaapi_encode.c, vaapi_transcode.c 예제 포팅
... 16  17  18  19  20  21  22  [23]  24  25  26  27  28  29  30  ...