[ElasticSearch] Fluentd와 연동

AnHyunDong·2022년 6월 27일
0

개요

  • 실시간 크롤링한 뉴스 데이터를 전달할 플랫폼이 필요함
  • Kafka -> Fluentd -> Elastic Search로 전달 예정
  • 들어온 데이터를 시각화 및 BI
  • 따라서 Fluentd <-> ES 연동이 필요함

제한사항

  • index_name 이름은 news(대문자가 들어가면 안됨)
  • 받는 데이터(네이버 뉴스)
    • 뉴스 제목
    • 신문사
    • 뉴스 장르(정치, IT, 생활, 세계 등 6개)
    • 뉴스 url
  • 현재 Bridge형태이므로 ES 외부 서비스를 열어줘야함

Troubleshooting

  • Kafka와 동일하게 외부의 데이터가 들어오지 않음
  • netstat -anlp :9200을 했을 때, 데이터가 들어오려는 움직임이 보임 > conf파일 문제
  • ElasticSearch의 default 값은 내부 데이터만 받는 것으로 되어있음 > ElasticSearch 통신을 외부 통신이 되게 바꿔줄 필요가 있음

해결방안

  • ElasticSearch의 네트워크 통신의 default 값은 내부서비스만 가능함 > 외부 프로토콜을 외부에서도 서비스를 받을 수 있도록 설정

코드

  • /etc/elasticsearch/elasticsearch.yml 코드 변경
  • 외부 프로토콜 통신이 될 수 있도록 변경
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/lib/elasticsearch
#
# Path to log files:
#
path.logs: /var/log/elasticsearch
#




# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
network.host: 0.0.0.0
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#





# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
#The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["0.0.0.0"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.

결과

  • 데이터가 들어오는 것을 확인할 수 있음
profile
사진은 남아 추억이 메모는 남아 스펙이 된다

0개의 댓글