본문 바로가기

카테고리 없음

[Elastic Search] 클러스터 구성하기

클러스터 이름은 같게 설정해야 함 (아님 다른 클러스터로 인식함)

클러스터 2개 - 노드 2개
클러스터 1개 - 노드 1개

#기존에 만든 elasticsearch 복사
$ cp -r es-716/ node-1


# config 파일 수정
vi config/elasticsearch.yml/
cluster.name: "cluster-1"
node.name: "node-1"

#실행
./bin/elasticserach

#이미 실행된 경우, 죽이고 다시 실행
$ ps -ef | grep elasticsearch
hyper       3542    2700  0 22:41 pts/0    00:00:00 grep --color=auto elasticsearch
$ kill 2700

#실행여부 확인
$ curl localhost:9200

$ cp -r node-1/ node-2
$ cp -r node-1/ node-3

#node-2 클러스터 수정
$ vi node-2/config/elasticsearch.yml
cluster.name: "cluster-1"
node.name: "node-2"

#node-2 실행
./node-2/bin/elasticsearch

# node-1, node-2 실행여부 확인
$ curl localhost:9200 # node-1
{
  "name" : "node-1",
  "cluster_name" : "es-cluster-1",
  "cluster_uuid" : "tc0vOTfZQKyoz3ahroQJKg",
  "version" : {
    "number" : "7.16.3",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "4e6e4eab2297e949ec994e688dad46290d018022",
    "build_date" : "2022-01-06T23:43:02.825887787Z",
    "build_snapshot" : false,
    "lucene_version" : "8.10.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

{
  "name" : "node-2",
  "cluster_name" : "es-cluster-1",
  "cluster_uuid" : "tc0vOTfZQKyoz3ahroQJKg",
  "version" : {
    "number" : "7.16.3",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "4e6e4eab2297e949ec994e688dad46290d018022",
    "build_date" : "2022-01-06T23:43:02.825887787Z",
    "build_snapshot" : false,
    "lucene_version" : "8.10.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}


index some documents 예제를 넣을 예정
node-1에 데이터를 넣을 예정
curl -X PUT "localhost:9200/customer/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
  "name": "John Doe"
}
'

--> [customer] creating index 로그가 찍힌 것을 확인할 수 있음.

curl localhost:9200/customer/_doc/1


############################################
#node-3 클러스터 수정
$ vi node-3/config/elasticsearch.yml
cluster.name: "cluster-2"
node.name: "node-1"


#node-3 실행
./node-3/bin/elasticsearch


보면, cluster-2에서는 내용 확인이 안됨.