{mongodb+elasticsearch+ kibana} feat docker-compose [quick start]

시훈·2024년 2월 2일
0

ElasticSearch

목록 보기
4/4
post-thumbnail

사전준비 : mongodb replicaset으로 구성하여 준비

structure

📦elastic
 ┣ 📂elasticsearch
 ┃ ┗ 📜dockerfile
 ┣ 📂monstache
 ┃ ┗ 📜monstache.config.toml
 ┗ 📜docker-compose.yaml

docker-compose.yaml

#docker-compose.yaml
version: '3.7'
services:
  elasticsearch:
    build:
      context: ./elasticsearch
    container_name: elasticsearch
    environment:
      - node.name=노드이름
      - discovery.type=single-node
      - cluster.name=클러스터이름
    ports:
      - 9200:9200
      - 9300:9300
    networks:
      - elasticsearch-bridge
    volumes:
      - elasticsearch-data:/usr/share/elasticsearch/data

  monstache:
    restart: always
    image: rwynn/monstache:6.7.11
    command: -f ./monstache.config.toml &
    volumes:
      - ./monstache/monstache.config.toml:/monstache.config.toml
    depends_on:
      - elasticsearch
    links:
      - elasticsearch
    ports:
      - '8080:8080'
    networks:
      - elasticsearch-bridge

  kibana:
    container_name: kibana
    image: docker.elastic.co/kibana/kibana:7.12.0
    environment:
      SERVER_NAME: kibana
      ELASTICSEARCH_HOSTS: http://elasticsearch:9200
    ports:
      - 5601:5601
    depends_on:
      - elasticsearch
    networks:
      - elasticsearch-bridge

networks:
  elasticsearch-bridge:
    driver: bridge

volumes:
  elasticsearch-data:

elasticsearch/dockerfile

#elasticsearch/dockerfile

FROM docker.elastic.co/elasticsearch/elasticsearch:7.12.0

RUN elasticsearch-plugin install analysis-nori

monstache/monstache.config.toml

# monstache/monstache.config.toml
# connect to MongoDB using the following URL
mongo-url = "MongoDB url"
# connect to the Elasticsearch REST API at the following node URLs
elasticsearch-urls = ["ElasticSearch Url들"]

# frequently required settings

# if you need to seed an index from a collection and not just listen and sync changes events
# you can copy entire collections or views from MongoDB to Elasticsearch
direct-read-namespaces = ["연결할 콜렉션(db.collection 형태로 입력해야 함)"]

# to listen to an entire db use only the database name.  For a deployment use an empty string.
change-stream-namespaces = ["추적할 콜렉션(db.collection 형태로 입력해야 함)"]

# compress requests to Elasticsearch
gzip = true
# generate indexing statistics
stats = true
# index statistics into Elasticsearch
index-stats = true

# use 4 go routines concurrently pushing documents to Elasticsearch
elasticsearch-max-conns = 4 

# propogate dropped collections in MongoDB as index deletes in Elasticsearch
dropped-collections = true
# propogate dropped databases in MongoDB as index deletes in Elasticsearch
dropped-databases = true

# in Elasticsearch with a newer version. Elasticsearch is preventing the old docs from overwriting new ones.
replay = false
# resume processing from a timestamp saved in a previous run
resume = true
# do not validate that progress timestamps have been saved
resume-write-unsafe = false
# override the name under which resume state is saved
resume-name = "default"
# use a custom resume strategy (tokens) instead of the default strategy (timestamps)
# tokens work with MongoDB API 3.6+ while timestamps work only with MongoDB API 4.0+
resume-strategy = 1
# turn on indexing of GridFS file content
index-files = true
# turn on search result highlighting of GridFS content
file-highlighting = true
# print detailed information including request traces
verbose = true

RUN

docker-compose -d --build

profile
생산성을 높이고, 집중을 즐기는 개발자

0개의 댓글