일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
- K-SW SQUARE
- 사파리 가상키보드
- ios 크로스브라우징
- activeElement
- Purdue university
- touchmove 이벤트
- but requested an insecure XMLHttpRequest endpoint 'http://~~’. This request has been blocked; the content must be served over HTTPS.
- Kafka
- 자바스크립트 옵셔널 체이닝
- 자바스크립트 null 병합
- AWS 로드밸런서
- 자바스크립트
- 모던 자바스크립트 Deep Dive
- 모두의시간
- 자바스
- 자바스크립트 중첩함수
- EC2 HTTPS로 연결
- 로현 청춘의개발
- net::R_SSL_PROTOCOL_ERROR
- 자바스크립트 호이스팅
- 자바스크립트 논리합 연산자
- active blur
- React Query
- refetchOnWindowFocus
- 자바스크립트 스코프 체인
- 퍼듀대학교
- 리액트 쿼리
- 자바스크립트 렉시컬스코프
- 리액트 가상키보드
- 자바스크립트 변수 호이스팅
- Today
- Total
개발 여행자, 현
[Docker] Docker Compose ELK 구축 본문
1. Docker-ELK Pull 받기
https://github.com/deviantony/docker-elk
git clone https://github.com/deviantony/docker-elk
Kafka와 ELK를 각각 Docker compose로 구성하면 Kafka와 LogStash 연동에 문제가 있을 수 있다.
Docker network는 default bridge이며, 기본적으로 같은 네트워크로 묶인 컨테이너끼리만 통신이 가능하기 때문이다.
docker network connect, 공용 외부 네트워크 생성으로 해결하는 방법도 있었지만 한번에 compose로 구성하는 방향으로 구현하고자 한다.
version: '3.2'
services:
elasticsearch:
build:
context: elasticsearch/
args:
ELK_VERSION: ${ELASTIC_VERSION}
volumes:
- type: bind
source: ./elasticsearch/config/elasticsearch.yml
target: /usr/share/elasticsearch/config/elasticsearch.yml
read_only: true
- type: volume
source: elasticsearch
target: /usr/share/elasticsearch/data
ports:
- "9200:9200"
- "9300:9300"
environment:
ES_JAVA_OPTS: "-Xmx256m -Xms256m"
# Use single node discovery in order to disable production mode and avoid bootstrap checks.
# see: [https://www.elastic.co/guide/en/elasticsearch/reference/current/bootstrap-checks.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/bootstrap-checks.html)
discovery.type: single-node
networks:
- kafka-elk
logstash:
build:
context: logstash/
args:
ELK_VERSION: ${ELASTIC_VERSION}
volumes:
- type: bind
source: ./logstash/config/logstash.yml
target: /usr/share/logstash/config/logstash.yml
read_only: true
- type: bind
source: ./logstash/pipeline
target: /usr/share/logstash/pipeline
read_only: true
ports:
- "5044:5044"
- "5000:5000/tcp"
- "5000:5000/udp"
- "9600:9600"
environment:
LS_JAVA_OPTS: "-Xmx256m -Xms256m"
networks:
- kafka-elk
depends_on:
- elasticsearch
kibana:
build:
context: kibana/
args:
ELK_VERSION: ${ELASTIC_VERSION}
volumes:
- type: bind
source: ./kibana/config/kibana.yml
target: /usr/share/kibana/config/kibana.yml
read_only: true
ports:
- "5601:5601"
networks:
- kafka-elk
depends_on:
- elasticsearch
zookeeper:
container_name: zookeeper
image: confluentinc/cp-zookeeper:latest
ports:
- "9900:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
networks:
- kafka-elk
kafka:
container_name: kafka
image: confluentinc/cp-kafka:latest
depends_on:
- zookeeper
ports:
- "9092:9092"
environment:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_CREATE_TOPICS: "test-topic:1:1"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- kafka-elk
networks:
kafka-elk:
driver: bridge
volumes:
elasticsearch:
Kafka environment 설정 부분에서
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092이처럼 설정하여
컨테이너 내부에선 kafka:29092 외부에선 localhost:9092접속이 가능하도록 설정한다.
2. docker compose 실행
docker compose를 실행하기 위해 아래 명령어를 입력하였다.
docker compose up -d
하지만 오류가 발생했다.
"failed to solve with frontend dockerfile. v0: failed to create LLB definition: unexpected status code [mamifests 3.8]: 400 Bad Request
아래와 같이 Docker Desktop을 리셋하면 해결이 되는 문제였다.

다시 명령어를 입력하면 성공이다!

접속포트는 아래와 같다.
Elasticsearch : localhost:9200
Logstash : localhost:5000/9600
Kibana : localhost:5601
Kafka : localhost:9092
3. 도커 네트워크 확인
전체 도커 네트워크 목록 확인 하는 명렁어는 아래와같다.
docker network ls

특정 네트워크 확인하고자 한다면 다음과 같이 입력한다. (docker-elk_kafka-elk)
docker network inspect {network name}

해당 네트워크에 모든 컨테이너가 모두 포함되어 있는 것을 확인할 수 있다.
4. logstash.config 파일 작성
# logstash.conf
input {
kafka {
bootstrap_servers => "kafka:29092"
topics => ["test0130"]
codec => plain
}
}
filter {
json {
source => "message"
}}
output {
elasticsearch {
hosts => "elasticsearch:9200"
index => "0214test"
user => "elastic"
password => "HkWUvu4z9ntU07yqXzFH"
}}
Kafka가 실행되고 있는 9092 포트에 데이터가 적재되는 것이 인식되면 9200 포트에서 실행되고 있는 Elasticsearch에 데이터를 적재하는 것이다.
시행착오


: node를 최신버전으로 다이렉트로 업그레이드 할 수 없다는 에러가 발생한 것을 확인할 수 있었고 7.17.0 버전으로 업데이트 후 8.6.0 업데이트를 한 번 더 진행해 해결했다.
Reference
1. https://www.elastic.co/guide/en/elasticsearch/reference/current/built-in-users.html
Built-in users | Elasticsearch Guide [8.7] | Elastic
Anyone who can log in as the elastic user has direct read-only access to restricted indices, such as .security. This user also has the ability to manage security and create roles with unlimited privileges.
www.elastic.co
Configuring Logstash for Docker | Logstash Reference [8.7] | Elastic
Bind-mounted configuration files will retain the same permissions and ownership within the container that they have on the host system. Be sure to set permissions such that the files will be readable and, ideally, not writeable by the container’s logstas
www.elastic.co
5. [Docker Kafka + ELK 연동] https://tries1.github.io/spring/2021/01/17/kafka_elk.html
'백엔드' 카테고리의 다른 글
[ELK] ELK 설치 (0) | 2023.02.28 |
---|---|
[Kafka, Springboot] 스프링부트 카프카 연동하기 (0) | 2023.02.28 |
[Kafka] 카프카란? (0) | 2023.02.28 |