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)
13194정성태12/14/20225004오류 유형: 833. warning C4747: Calling managed 'DllMain': Managed code may not be run under loader lock파일 다운로드1
13193정성태12/14/20225055오류 유형: 832. error C7681: two-phase name lookup is not supported for C++/CLI or C++/CX; use /Zc:twoPhase-
13192정성태12/13/20225058Linux: 55. 리눅스 - bash shell에서 실수 연산
13191정성태12/11/20225976.NET Framework: 2077. C# - 직접 만들어 보는 SynchronizationContext파일 다운로드1
13190정성태12/9/20226436.NET Framework: 2076. C# - SynchronizationContext 기본 사용법파일 다운로드1
13189정성태12/9/20227052오류 유형: 831. Visual Studio - Windows Forms 디자이너의 도구 상자에 컨트롤이 보이지 않는 문제
13188정성태12/9/20225912.NET Framework: 2075. C# - 직접 만들어 보는 TaskScheduler 실습 (SingleThreadTaskScheduler)파일 다운로드1
13187정성태12/8/20225842개발 환경 구성: 654. openssl - CA로부터 인증받은 새로운 인증서를 생성하는 방법 (2)
13186정성태12/6/20224367오류 유형: 831. The framework 'Microsoft.AspNetCore.App', version '...' was not found.
13185정성태12/6/20225350개발 환경 구성: 653. Windows 환경에서의 Hello World x64 어셈블리 예제 (NASM 버전)
13184정성태12/5/20224652개발 환경 구성: 652. ml64.exe와 link.exe x64 실행 환경 구성
13183정성태12/4/20224496오류 유형: 830. MASM + CRT 함수를 사용하는 경우 발생하는 컴파일 오류 정리
13182정성태12/4/20225201Windows: 217. Windows 환경에서의 Hello World x64 어셈블리 예제 (MASM 버전)
13181정성태12/3/20224605Linux: 54. 리눅스/WSL - hello world 어셈블리 코드 x86/x64 (nasm)
13180정성태12/2/20224838.NET Framework: 2074. C# - 스택 메모리에 대한 여유 공간 확인하는 방법파일 다운로드1
13179정성태12/2/20224257Windows: 216. Windows 11 - 22H2 업데이트 이후 Terminal 대신 cmd 창이 뜨는 경우
13178정성태12/1/20224735Windows: 215. Win32 API 금지된 함수 - IsBadXxxPtr 유의 함수들이 안전하지 않은 이유파일 다운로드1
13177정성태11/30/20225445오류 유형: 829. uwsgi 설치 시 fatal error: Python.h: No such file or directory
13176정성태11/29/20224383오류 유형: 828. gunicorn - ModuleNotFoundError: No module named 'flask'
13175정성태11/29/20225943오류 유형: 827. Python - ImportError: cannot import name 'html5lib' from 'pip._vendor'
13174정성태11/28/20224568.NET Framework: 2073. C# - VMMap처럼 스택 메모리의 reserve/guard/commit 상태 출력파일 다운로드1
13173정성태11/27/20225242.NET Framework: 2072. 닷넷 응용 프로그램의 스레드 스택 크기 변경
13172정성태11/25/20225094.NET Framework: 2071. 닷넷에서 ESP/RSP 레지스터 값을 구하는 방법파일 다운로드1
13171정성태11/25/20224678Windows: 214. 윈도우 - 스레드 스택의 "red zone"
13170정성태11/24/20224980Windows: 213. 윈도우 - 싱글 스레드는 컨텍스트 스위칭이 없을까요?
13169정성태11/23/20225593Windows: 212. 윈도우의 Protected Process (Light) 보안 [1]파일 다운로드2
... 16  [17]  18  19  20  21  22  23  24  25  26  27  28  29  30  ...