본문으로 바로가기

Docker + Elasticsearch, Kibana 구성 (cluster)

category docker 2022. 7. 12. 18:37
반응형


 

 

https://github.com/lgm3555/todo-docker/tree/master/docker-elk-setting

 

구성

1. node는 총 3개 구성

2. node1, node2는 master node 겸 data node 사용

3. node3은 data node로만 사용

# elasticsearch image
docker.elastic.co/elasticsearch/elasticsearch:7.9.1

# kibana image
docker.elastic.co/kibana/kibana:7.9.1

docker-compose.yml

version: "3.3"
services:
        es1:
                # elasticsearch 이미지 다운로드
                image: docker.elastic.co/elasticsearch/elasticsearch:7.9.1
                # 컨테이너 명 설정
                container_name: es1
                # 포트 설정
                ports:
                        - 9200:9200
                        - 9300:9300
                environment:
                        # es node 명
                        - node.name=es1
                        # cluster 명 (es1,es2,es3 동일한 명칭으로 설정)
                        - cluster.name=es-docker-cluster
                        # cluster를 구성하는 다른 node 명시
                        - discovery.seed_hosts=es2,es3
                        # master node es1,es2 명시
                        - cluster.initial_master_nodes=es1,es2
                        # es1은 data node, master node
                        - node.roles=data,master
                # 리눅스 시스템 자원제한 관련 옵션
                ulimits:
                        memlock:
                                soft: -1
                                hard: -1
                # data01 mount 설정
                volumes:
                        - /home/danawa/volumes/data01:/usr/share/elasticsearch/data
                # es1,es2,es3 동일한 network 설정
                networks:
                        - elastic-net
        es2:
                image: docker.elastic.co/elasticsearch/elasticsearch:7.9.1
                container_name: es2
                ports:
                        - 9201:9200
                        - 9301:9300
                environment:
                        - node.name=es2
                        - cluster.name=es-docker-cluster
                        - discovery.seed_hosts=es1,es3
                        - cluster.initial_master_nodes=es1,es2
                        - node.roles=data,master
                ulimits:
                        memlock:
                                soft: -1
                                hard: -1
                volumes:
                        - /home/danawa/volumes/data02:/usr/share/elasticsearch/data
                networks:
                        - elastic-net
        es3:
                image: docker.elastic.co/elasticsearch/elasticsearch:7.9.1
                container_name: es3
                ports:
                        - 9202:9200
                        - 9302:9300
                environment:
                        - node.name=es2
                        - cluster.name=es-docker-cluster
                        - discovery.seed_hosts=es1,es2
                        - cluster.initial_master_nodes=es1,es2
                        - node.roles=data
                ulimits:
                        memlock:
                                soft: -1
                                hard: -1
                volumes:
                        - /home/danawa/volumes/data03:/usr/share/elasticsearch/data
                networks:
                        - elastic-net
        kibana:
                # es1,es2,es3 다음 실행
                depends_on:
                        - es1
                        - es2
                        - es3
                # kibana 이미지 다운로드
                image: docker.elastic.co/kibana/kibana:7.9.1
                container_name: kibana
                ports:
                        - 5601:5601
				# es1 node 연결
				links:
                        - es1:es1
                environment:
                        - server.name=kibana
                        - server.host=0
                        - ELASTICSEARCH_HOSTS=http://es1:9200
                networks:
                        - elastic-net
networks:
        elastic-net: {}
volumes:
        data01:
                driver: local
        data02:
                driver: local
        data03:
                driver: local

docker-compose up -d

Starting es1 ... done
Starting es2 ... done
Starting es3 ... done
Starting kibana ... done

es1 : http://localhost:9200

{
  "name" : "es1",
  "cluster_name" : "es-docker-cluster",
  "cluster_uuid" : "ii180hjWQEqKgA6_HZObEw",
  "version" : {
    "number" : "7.9.1",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "083627f112ba94dffc1232e8b42b73492789ef91",
    "build_date" : "2020-09-01T21:22:21.964974Z",
    "build_snapshot" : false,
    "lucene_version" : "8.6.2",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

es2 : http://locahost:9201

{
  "name" : "es2",
  "cluster_name" : "es-docker-cluster",
  "cluster_uuid" : "ii180hjWQEqKgA6_HZObEw",
  "version" : {
    "number" : "7.9.1",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "083627f112ba94dffc1232e8b42b73492789ef91",
    "build_date" : "2020-09-01T21:22:21.964974Z",
    "build_snapshot" : false,
    "lucene_version" : "8.6.2",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

ec3: http://localhost:9202

{
  "name" : "es3",
  "cluster_name" : "es-docker-cluster",
  "cluster_uuid" : "ii180hjWQEqKgA6_HZObEw",
  "version" : {
    "number" : "7.9.1",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "083627f112ba94dffc1232e8b42b73492789ef91",
    "build_date" : "2020-09-01T21:22:21.964974Z",
    "build_snapshot" : false,
    "lucene_version" : "8.6.2",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

현재 노드 확인

http://localhost:9200/_cat/nodes

172.24.0.2 19 45 1 0.19 0.36 0.59 d  - es3
172.24.0.4 59 45 1 0.19 0.36 0.59 dm - es2
172.24.0.3 16 45 1 0.19 0.36 0.59 dm * es1

http://localhost:9201/_nodes/process?pretty=true

{
  "_nodes" : {
    "total" : 3,
    "successful" : 3,
    "failed" : 0
  },
  "cluster_name" : "es-docker-cluster",
  "nodes" : {
    "pg_DjdG8TfODE51pLiD2eg" : {
      "name" : "es3",
      "transport_address" : "172.24.0.2:9300",
      "host" : "172.24.0.2",
      "ip" : "172.24.0.2",
      "version" : "7.9.1",
      "build_flavor" : "default",
      "build_type" : "docker",
      "build_hash" : "083627f112ba94dffc1232e8b42b73492789ef91",
      "roles" : [
        "data"
      ],
      "attributes" : {
        "xpack.installed" : "true",
        "transform.node" : "false"
      },
      "process" : {
        "refresh_interval_in_millis" : 1000,
        "id" : 7,
        "mlockall" : false
      }
    },
    "z1UQ6sQ3TZ6JeljO7pRLbA" : {
      "name" : "es2",
      "transport_address" : "172.24.0.4:9300",
      "host" : "172.24.0.4",
      "ip" : "172.24.0.4",
      "version" : "7.9.1",
      "build_flavor" : "default",
      "build_type" : "docker",
      "build_hash" : "083627f112ba94dffc1232e8b42b73492789ef91",
      "roles" : [
        "data",
        "master"
      ],
      "attributes" : {
        "xpack.installed" : "true",
        "transform.node" : "false"
      },
      "process" : {
        "refresh_interval_in_millis" : 1000,
        "id" : 7,
        "mlockall" : false
      }
    },
    "h4p0Dud-TuqYnSYm8ovR3Q" : {
      "name" : "es1",
      "transport_address" : "172.24.0.3:9300",
      "host" : "172.24.0.3",
      "ip" : "172.24.0.3",
      "version" : "7.9.1",
      "build_flavor" : "default",
      "build_type" : "docker",
      "build_hash" : "083627f112ba94dffc1232e8b42b73492789ef91",
      "roles" : [
        "data",
        "master"
      ],
      "attributes" : {
        "xpack.installed" : "true",
        "transform.node" : "false"
      },
      "process" : {
        "refresh_interval_in_millis" : 1000,
        "id" : 7,
        "mlockall" : false
      }
    }
  }
}

cat api 목록

=^.^=
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_cat/tasks
/_cat/indices
/_cat/indices/{index}
/_cat/segments
/_cat/segments/{index}
/_cat/count
/_cat/count/{index}
/_cat/recovery
/_cat/recovery/{index}
/_cat/health
/_cat/pending_tasks
/_cat/aliases
/_cat/aliases/{alias}
/_cat/thread_pool
/_cat/thread_pool/{thread_pools}
/_cat/plugins
/_cat/fielddata
/_cat/fielddata/{fields}
/_cat/nodeattrs
/_cat/repositories
/_cat/snapshots/{repository}
/_cat/templates
/_cat/ml/anomaly_detectors
/_cat/ml/anomaly_detectors/{job_id}
/_cat/ml/trained_models
/_cat/ml/trained_models/{model_id}
/_cat/ml/datafeeds
/_cat/ml/datafeeds/{datafeed_id}
/_cat/ml/data_frame/analytics
/_cat/ml/data_frame/analytics/{id}
/_cat/transforms
/_cat/transforms/{transform_id}

 

반응형