본문 바로가기
BigData

Apache Flume 맛보기

by david100gom 2019. 3. 12.
728x90

Apache Flume


Apache Flume is a distributed, reliable, and available service for efficiently collecting, aggregating, and moving large amounts of log data. Its main goal is to deliver data from applications to Apache Hadoop's HDFS. It has a simple and flexible architecture based on streaming data flows. It is robust and fault tolerant with tunable reliability mechanisms and many failover and recovery mechanisms.

  • 핵심 키워드 : Its main goal is to deliver data from applications to Apache Hadoop's HDFS (주요 목표는 응용 프로그램에서 아파치 Hadoop의 HDFS에 데이터를 제공하는 것 - Flume agent 를 이용하여, Flume Server 에 데이터를 전송하는 것이 핵심 키워드입니다.)

Flume 의 기본 아키텍처

연동 테스트


기본 샘플 예제를 통하여 연동 테스트를 진행해 보도록 하겠습니다. 

(https://cwiki.apache.org/confluence/display/FLUME/Getting+Started 페이지에 기본적으로 구동 예제를 실행할수 있습니다. 해당 내용을 가지고, 테스트를 진행하도록 하겠습니다.)

1
2
3
4
$ tar -zxvf apache-flume-1.3.1-bin.tar.gz
$ cd apache-flume-1.3.1-bin
$ cp conf/flume-conf.properties.template conf/flume.conf
$ cp conf/flume-env.sh.template conf/flume-env.sh

cs

  • flume.conf 에 아래의 내용을 복사해 넣습니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Define a memory channel called ch1 on agent1
 
agent1.channels.ch1.type = memory
# Define an Avro source called avro-source1 on agent1 and tell it
# to bind to 0.0.0.0:41414. Connect it to channel ch1.
agent1.sources.avro-source1.channels = ch1
agent1.sources.avro-source1.type = avro
agent1.sources.avro-source1.bind = 0.0.0.0
agent1.sources.avro-source1.port = 41414
 
# Define a logger sink that simply logs all events it receives
# and connect it to the other end of the same channel.
agent1.sinks.log-sink1.channel = ch1
agent1.sinks.log-sink1.type = logger
 
# Finally, now that we've defined all of our components, tell
# agent1 which ones we want to activate.
agent1.channels = ch1
agent1.sources = avro-source1
agent1.sinks = log-sink
cs
  • Flume Server 를 구동합니다.
1
$ bin/flume-ng agent --conf ./conf/ -f conf/flume.conf -Dflume.root.logger=DEBUG,console -n agent1
cs

아래와 같이 나타나면 구동이 제대로 완료된 것입니다.

이제는 agent 를 구동해 보도록 하겠습니다. 기본적으로 1대의 서버와 1대 ~ 여러대의 agent 가지고 테스트를 해야 하지만,  지금은 localhost에서 server 와 agent 를 구동하여 예제 테스트를 진행하도록 하겠습니다.

1
$ bin/flume-ng avro-client --conf conf -H localhost -41414 -/etc/passwd -Dflume.root.logger=DEBUG,console
cs
  • 상기 agent 는 avro RPC 방식으로 서버로 전달하는 예제이며, -H 는 서버 호스트 네임, -p 는 포트번호, -F 는 내용을전송할 파일명입니다. Flume 의 아키텍처상 서버도 하나의 agent 입니다. avro RPC client agent 를 구동하면, /etc/passwd 파일의 내용이 서버 agent 로 전송됩니다.

 

예제 테스트


여기서는 좀더 확인하기 쉽게 Test.txt 파일을 임의로 만들고, 테스트 해보도록 하겠습니다. Test.txt 에 Hello Flume 이라고 작성후 저장합니다. 그럼 Test.txt 의 내용하는 전송하는 테스트를 진행하겠습니다.

1
$ bin/flume-ng avro-client --conf conf -H localhost -41414 -F Test.txt -Dflume.root.logger=DEBUG,console
cs

아래와 같이 나오면 제대로 서버로 전송이 제대로 완료된 것입니다.

그리고, 아래는 서버쪽 로그입니다. 아래와 화면과 같이 "Hello Flume"가 찍히면 수신이 제대로 완료된 것입니다.

여러가지 고급설정 및 구성은 http://flume.apache.org/documentation.html 페이지를 활용하여 구성하시면 됩니다. 그리고, 위의 테스트 예제는 서버쪽 콘솔에 수신내용을 찍는 예제이며, 수신내용을 파일, HDFS 등으로 저장하는 내용은 상기 가이드 페이지를 보시면,  구성하실 수 있습니다. 또한, conf/flume.conf 파일의 구성파일을 수정함으로써 세부적인 설정을 조정할 수 있습니다

 

지금까지 Apache Flume 맛보기 였습니다.

728x90

'BigData' 카테고리의 다른 글

하둡 Cloudera Manager 설치  (0) 2020.10.05
8 Best Big Data Tools in 2020  (0) 2020.09.19
엔터프라이즈 데이터 플랫폼 구축하기 1탄  (0) 2020.09.19
Kafka 핵심 포인트  (0) 2020.09.19
IoT 에서의 네트워크 엔진  (0) 2019.10.12
JMeter 사용법  (0) 2019.05.05
MQTT  (0) 2015.06.17
참고서적  (1) 2013.01.14

댓글