본문 바로가기
elastic-stack

VM을 활용한 Elastic Stack 실습 환경 구축 3 - cluster 기본 설정

by jiseok.woo 2020. 1. 16.
반응형

 

 

 

 

 

 

 

이전 포스팅에서 정말 기본적인 elasticsearch 설정을 해보았다. 지금부터는 3개 node로 cluster를 구성해보자.

 

진행하기에 앞서 이전 포스팅에서와 같이 elastic2, elastic3 VM도 동일하게 file descriptor, vm.max_map_count 값 변경 해준 뒤 방화벽 disable해주자.

 

 


 

 

1. node-1 설정

 

[elastic@elastic1 elasticsearch-7.5.1]$ vi config/elasticsearch.yml 
cluster.name: elastic-cluster
node.name: node-1
network.host: 192.168.100.11
discovery.seed_hosts: ["192.168.100.11", "192.168.100.12", "192.168.100.13"]
cluster.initial_master_nodes: ["node-1"]

node.master: true
node.data: false
node.ingest: false
node.ml: false

 

  • cluster.name : 클러스터 이름이다. 이 이름이 같아야 동일 cluster로 인식할 수 있다.
  • node.name : 노드 이름이다. 이전에 설정해봤으니 넘어가자.
  • network.host : 노드의 IP다. 이것도 넘어가자.
  • discovery.seed_hosts : cluster를 구성할 node의 리스트라 보면 된다. 자기 자신 및 다른 node들의 IP를 적어준다.
  • cluster.initial_master_nodes : master 후보 노드의 리스트다. 이번 cluster는 node가 3개 뿐이라 일단 matser를 하나로 지정해보자.
  • node.master, node,data, node.ingest, node.ml은 node의 기능을 나타내는데 master, data, ingest 및 machine learning이다.
  • node-1은 마스터 노드이므로 master만 true, 나머지는 false로 설정하자.

 

 

2. node-2 설정

node-2는 아래와 같이 설정하자. (위에 설명 잔뜩 해놨으니 생략하겠다.)

[elastic@elastic2 elasticsearch-7.5.1]$ vi config/elasticsearch.yml 
cluster.name: elastic-cluster
node.name: node-2
network.host: 192.168.100.12
discovery.seed_hosts: ["192.168.100.11", "192.168.100.12", "192.168.100.13"]
cluster.initial_master_nodes: ["node-1"]

node.master: false
node.data: true
node.ingest: false
node.ml: false

 

  • node-2, node-3은 데이터 노드이니 node.master는 false, node.data는 true로 설정하자.

 

 

3. node-3 설정

node-3은 아래와 같이 설정하자.

[elastic@elastic3 elasticsearch-7.5.1]$ vi config/elasticsearch.yml 
cluster.name: elastic-cluster
node.name: node-3
network.host: 192.168.100.13
discovery.seed_hosts: ["192.168.100.11", "192.168.100.12", "192.168.100.13"]
cluster.initial_master_nodes: ["node-1"]

node.master: false
node.data: true
node.ingest: false
node.ml: false

 

 

4. elasticsearch 서비스 실행

 

자, 그럼 node-1 부터 node-3까지 차례로 elasticsearch를 실행해보자.

 

  • node-1
[2020-01-16T09:20:34,011][INFO ][o.e.c.s.MasterService    ] [node-1] elected-as-master ([1] nodes joined)[{node-1}{rjL_1th7TPqPPBvu12ssyQ}{WXOHu6GBR7eThRvlcX0yow}{192.168.100.11}{192.168.100.11:9300}{m}{xpack.installed=true} elect leader, _BECOME_MASTER_TASK_, _FINISH_ELECTION_], term: 2, version: 22, delta: master node changed {previous [], current [{node-1}{rjL_1th7TPqPPBvu12ssyQ}{WXOHu6GBR7eThRvlcX0yow}{192.168.100.11}{192.168.100.11:9300}{m}{xpack.installed=true}]}
[2020-01-16T09:20:34,187][INFO ][o.e.c.s.ClusterApplierService] [node-1] master node changed {previous [], current [{node-1}{rjL_1th7TPqPPBvu12ssyQ}{WXOHu6GBR7eThRvlcX0yow}{192.168.100.11}{192.168.100.11:9300}{m}{xpack.installed=true}]}, term: 2, version: 22, reason: Publication{term=2, version=22}
[2020-01-16T09:20:34,497][INFO ][o.e.h.AbstractHttpServerTransport] [node-1] publish_address {192.168.100.11:9200}, bound_addresses {192.168.100.11:9200}
[2020-01-16T09:20:34,498][INFO ][o.e.n.Node               ] [node-1] started
[2020-01-16T09:20:34,843][INFO ][o.e.l.LicenseService     ] [node-1] license [f8a5d59a-0e24-4b34-93cd-21d059552e3c] mode [basic] - valid
[2020-01-16T09:20:34,844][INFO ][o.e.x.s.s.SecurityStatusChangeListener] [node-1] Active license is now [BASIC]; Security is disabled
[2020-01-16T09:20:34,865][INFO ][o.e.g.GatewayService     ] [node-1] recovered [0] indices into cluster_state
[2020-01-16T09:20:43,981][INFO ][o.e.c.s.MasterService    ] [node-1] node-join[{node-2}{Q1wc3K3PRXGTjW3eJo4YUg}{HatqlazRTryE7WWQIwcozg}{192.168.100.12}{192.168.100.12:9300}{d}{xpack.installed=true} join existing leader], term: 2, version: 25, delta: added {{node-2}{Q1wc3K3PRXGTjW3eJo4YUg}{HatqlazRTryE7WWQIwcozg}{192.168.100.12}{192.168.100.12:9300}{d}{xpack.installed=true}}
[2020-01-16T09:20:45,131][INFO ][o.e.c.s.ClusterApplierService] [node-1] added {{node-2}{Q1wc3K3PRXGTjW3eJo4YUg}{HatqlazRTryE7WWQIwcozg}{192.168.100.12}{192.168.100.12:9300}{d}{xpack.installed=true}}, term: 2, version: 25, reason: Publication{term=2, version=25}
[2020-01-16T09:21:00,108][INFO ][o.e.c.s.MasterService    ] [node-1] node-join[{node-3}{jcCP4SbkR8OL0fO3UZrAsw}{UrlYArwFSWGvM4oy9ubLIQ}{192.168.100.13}{192.168.100.13:9300}{d}{xpack.installed=true} join existing leader], term: 2, version: 26, delta: added {{node-3}{jcCP4SbkR8OL0fO3UZrAsw}{UrlYArwFSWGvM4oy9ubLIQ}{192.168.100.13}{192.168.100.13:9300}{d}{xpack.installed=true}}
[2020-01-16T09:21:01,276][INFO ][o.e.c.s.ClusterApplierService] [node-1] added {{node-3}{jcCP4SbkR8OL0fO3UZrAsw}{UrlYArwFSWGvM4oy9ubLIQ}{192.168.100.13}{192.168.100.13:9300}{d}{xpack.installed=true}}, term: 2, version: 26, reason: Publication{term=2, version=26}

 

  • node-2
[2020-01-16T09:20:44,077][INFO ][o.e.c.s.ClusterApplierService] [node-2] master node changed {previous [], current [{node-1}{rjL_1th7TPqPPBvu12ssyQ}{WXOHu6GBR7eThRvlcX0yow}{192.168.100.11}{192.168.100.11:9300}{m}{xpack.installed=true}]}, added {{node-1}{rjL_1th7TPqPPBvu12ssyQ}{WXOHu6GBR7eThRvlcX0yow}{192.168.100.11}{192.168.100.11:9300}{m}{xpack.installed=true}}, term: 2, version: 25, reason: ApplyCommitRequest{term=2, version=25, sourceNode={node-1}{rjL_1th7TPqPPBvu12ssyQ}{WXOHu6GBR7eThRvlcX0yow}{192.168.100.11}{192.168.100.11:9300}{m}{xpack.installed=true}}
[2020-01-16T09:20:44,737][INFO ][o.e.x.s.a.TokenService   ] [node-2] refresh keys
[2020-01-16T09:20:44,997][INFO ][o.e.x.s.a.TokenService   ] [node-2] refreshed keys
[2020-01-16T09:20:45,076][INFO ][o.e.l.LicenseService     ] [node-2] license [f8a5d59a-0e24-4b34-93cd-21d059552e3c] mode [basic] - valid
[2020-01-16T09:20:45,077][INFO ][o.e.x.s.s.SecurityStatusChangeListener] [node-2] Active license is now [BASIC]; Security is disabled
[2020-01-16T09:20:45,180][INFO ][o.e.h.AbstractHttpServerTransport] [node-2] publish_address {192.168.100.12:9200}, bound_addresses {192.168.100.12:9200}
[2020-01-16T09:20:45,181][INFO ][o.e.n.Node               ] [node-2] started
[2020-01-16T09:21:00,200][INFO ][o.e.c.s.ClusterApplierService] [node-2] added {{node-3}{jcCP4SbkR8OL0fO3UZrAsw}{UrlYArwFSWGvM4oy9ubLIQ}{192.168.100.13}{192.168.100.13:9300}{d}{xpack.installed=true}}, term: 2, version: 26, reason: ApplyCommitRequest{term=2, version=26, sourceNode={node-1}{rjL_1th7TPqPPBvu12ssyQ}{WXOHu6GBR7eThRvlcX0yow}{192.168.100.11}{192.168.100.11:9300}{m}{xpack.installed=true}}

 

  • node-3
[2020-01-16T09:21:00,140][INFO ][o.e.c.s.ClusterApplierService] [node-3] master node changed {previous [], current [{node-1}{rjL_1th7TPqPPBvu12ssyQ}{WXOHu6GBR7eThRvlcX0yow}{192.168.100.11}{192.168.100.11:9300}{m}{xpack.installed=true}]}, added {{node-1}{rjL_1th7TPqPPBvu12ssyQ}{WXOHu6GBR7eThRvlcX0yow}{192.168.100.11}{192.168.100.11:9300}{m}{xpack.installed=true},{node-2}{Q1wc3K3PRXGTjW3eJo4YUg}{HatqlazRTryE7WWQIwcozg}{192.168.100.12}{192.168.100.12:9300}{d}{xpack.installed=true}}, term: 2, version: 26, reason: ApplyCommitRequest{term=2, version=26, sourceNode={node-1}{rjL_1th7TPqPPBvu12ssyQ}{WXOHu6GBR7eThRvlcX0yow}{192.168.100.11}{192.168.100.11:9300}{m}{xpack.installed=true}}
[2020-01-16T09:21:00,791][INFO ][o.e.x.s.a.TokenService   ] [node-3] refresh keys
[2020-01-16T09:21:01,093][INFO ][o.e.x.s.a.TokenService   ] [node-3] refreshed keys
[2020-01-16T09:21:01,171][INFO ][o.e.l.LicenseService     ] [node-3] license [f8a5d59a-0e24-4b34-93cd-21d059552e3c] mode [basic] - valid
[2020-01-16T09:21:01,172][INFO ][o.e.x.s.s.SecurityStatusChangeListener] [node-3] Active license is now [BASIC]; Security is disabled
[2020-01-16T09:21:01,352][INFO ][o.e.h.AbstractHttpServerTransport] [node-3] publish_address {192.168.100.13:9200}, bound_addresses {192.168.100.13:9200}
[2020-01-16T09:21:01,353][INFO ][o.e.n.Node               ] [node-3] started

 

순서대로 실행했기 때문에 로그도 node-1에서 보면 node-2가 cluster에 join하고 그 뒤에 node-3가 join했다는 메세지를 볼 수 있다.

3개 node 모두 정상적으로 실행되었다.

 

 

 

 

5. cluster 상태 확인

이제 맥북에서 아래 명령을 통해 cluster의 상태를 확인해보자.

(아래 명령은 REST API를 통해 cluster의 상태를 확인하는 걸로만 알고 넘어가자.)

Jiseokui-MacBookPro:~ jiseokwoo$ curl http://192.168.100.11:9200/_cluster/health
{"cluster_name":"elastic-cluster","status":"green","timed_out":false,"number_of_nodes":3,"number_of_data_nodes":2,"active_primary_shards":0,"active_shards":0,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":0,"delayed_unassigned_shards":0,"number_of_pending_tasks":0,"number_of_in_flight_fetch":0,"task_max_waiting_in_queue_millis":0,"active_shards_percent_as_number":100.0}Jiseokui-MacBookPro:~ jiseokwoo$ 

 

뭐 데이터가 오긴했는데 알아보기 힘들다. 아래처럼 뒤에 "?pretty"를 붙여서 전송하면 데이터가 이쁘게 온다.

Jiseokui-MacBookPro:~ jiseokwoo$ curl http://192.168.100.11:9200/_cluster/health?pretty
{
  "cluster_name" : "elastic-cluster",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 3,
  "number_of_data_nodes" : 2,
  "active_primary_shards" : 0,
  "active_shards" : 0,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}
Jiseokui-MacBookPro:~ jiseokwoo$ 

 

보기가 한결 편하네. ?pretty는 elasticsearch에서 전역으로 사용 가능하니 꼭 기억해두자.

응답 받은 데이터를 보면 cluster의 이름과 상태(green이니 좋다.) 및 node의 개수 등이 나온다.

우리는 3개 node로 구성했으니 number of nodes가 3으로 표기되었고 1개의 master, 2개의 data node로 구성해 number of data nodes가 2로 표기되어 있다.

 

 

 

 

 

 

아주 간단한 설정만으로 cluster를 구성해보았다.

다음 포스팅부터는 기본적인 indexing부터 복잡한 쿼리들까지 차근차근 실습해보자.

 

 

 

끝.

 

 

 

 

2020/01/11 - [elastic-stack] - VM을 활용한 Elastic Stack 실습 환경 구축 1 - VM 생성하기

2020/01/16 - [elastic-stack] - VM을 활용한 Elastic Stack 실습 환경 구축 2 - elasticsearch 기본 설정

2020/01/16 - [elastic-stack] - VM을 활용한 Elastic Stack 실습 환경 구축 3 - cluster 기본 설정

2020/01/24 - [elastic-stack] - VM을 활용한 Elastic Stack 실습 환경 구축 4 - kibana 기본 설정

 

 

반응형

댓글