[Flume] Flume 설치부터 예제까지...

 
Flume OG는 구버전이니 Flume NG를 사용하여 설치부터 사용 예제까지 포스팅 하겠습니다. 여러 머신에서 사용하려면 각각의 머신에 동일하게 Flume를 설치해야 되며 Hadoop이 설치되어있다면 Flume의 라이브러리를 Hadoop 라이브러리에 복사해야 됩니다.

설치
  • http://flume.apache.org/download.html 에서 Apache Flume binary(tar.gz)를 다운로드 받습니다.
  • tar -xvfz apache-flume-1.3.1-bin.tar.gz 
  • ln -s apache-flume-1.3.1-bin.tar.gz flume
 
환경변수 설정 
export FLUME_HOME=/apps/apache-flume-1.3.1-bin.tar.gz
PATH=$PATH:$HOME/bin:${FLUME_HOME}/bin
export PATH

환경설정
  • cd flume
  • cp flume-conf.properties.template flume.conf
  • vi flume.conf
 
# The configuration file needs to define the sources, 
# the channels and the sinks.
# Sources, channels and sinks are defined per agent, 
# in this case called 'agent'

agent.sources = seqGenSrc
agent.channels = memoryChannel
agent.sinks = loggerSink

# For each one of the sources, the type is defined
agent.sources.seqGenSrc.type = seq //source 타입

# The channel can be defined as follows.
agent.sources.seqGenSrc.channels = memoryChannel  // source를 channel과 연결

# Each sink's type must be defined
agent.sinks.loggerSink.type = logger  // sink 타입

#Specify the channel the sink should use
agent.sinks.loggerSink.channel = memoryChannel  // sink를 channel과 연결

# Each channel's type is defined.
agent.channels.memoryChannel.type = memory //channel 타입

# Other config values specific to each type of channel(sink or source)
# can be defined as well
# In this case, it specifies the capacity of the memory channel
agent.channels.memoryChannel.capacity = 100 // channel의 용량

이 파일에서 Source, Sink, Channel를 어떻게 설정하냐에 따라 여러 Flow을 구성 하실 수가 있습니다.

환경설정 샘플
제가 구축한 설정은 서버1, 서버2, 서버3에다가 각각 Flume을 설치한 후 서버1에서는 서버2와 서버3에서 보내는 데이터를 파일로 저장합니다. 서버2와 서버3은 로그파일을 읽어 서버 1로 보내줍니다.

서버1 flume.conf
agent01.sources = avroGenSrc
agent01.channels = memoryChannel
agent01.sinks = fileSink

# For each one of the sources, the type is defined
agent01.sources.avroGenSrc.type = avro
agent01.sources.avroGenSrc.bind = localhost
agent01.sources.avroGenSrc.port = 3333

# The channel can be defined as follows.
agent01.sources.avroGenSrc.channels = memoryChannel

# Each sink's type must be defined
agent01.sinks.fileSink.type = file_roll
agent01.sinks.fileSink.sink.directory = /home/aaaaa/flume/data
agent01.sinks.fileSink.sink.rollInterval = 30
agent01.sinks.fileSink.sink.batchSize = 100


#Specify the channel the sink should use
agent01.sinks.fileSink.channel = memoryChannel

# Each channel's type is defined.
agent01.channels.memoryChannel.type = memory

# Other config values specific to each type of channel(sink or source)
# can be defined as well
# In this case, it specifies the capacity of the memory channel
agent01.channels.memoryChannel.capacity = 100000
agent01.channels.memoryChannel.transactionCapacity = 10000


서버2, 서버3 flume.conf
서버2와 서버3의 환경설정은 똑같습니다. 단지 agent 명만 다릅니다.
agent02.sources = execGenSrc
agent02.channels = memoryChannel
agent02.sinks = avroSink

# For each one of the sources, the type is defined
agent02.sources.execGenSrc.type = exec
agent02.sources.execGenSrc.command = tail -F /home/aaaaa/hadoop/logs/logsample.log
agent02.sources.execGenSrc.batchSize = 10

# The channel can be defined as follows.
agent02.sources.execGenSrc.channels = memoryChannel

# Each sink's type must be defined
agent02.sinks.avroSink.type = avro
agent02.sinks.avroSink.hostname = 데이타가 보내져야될 호스트 주소
agent02.sinks.avroSink.port = 3333
agent02.sinks.avroSink.batch-size = 10


#Specify the channel the sink should use
agent02.sinks.avroSink.channel = memoryChannel

# Each channel's type is defined.
agent02.channels.memoryChannel.type = memory

# Other config values specific to each type of channel(sink or source)
# can be defined as well
# In this case, it specifies the capacity of the memory channel
agent02.channels.memoryChannel.capacity = 100000
agent02.channels.memoryChannel.transactionCapacity = 10000

실행
 
  • ./bin/flume-ng agent --conf-file ./conf/flume.conf --name agent01
  • ./bin/flume-ng agent --conf-file ./conf/flume.conf --name agent02
  • ./bin/flume-ng agent --conf-file ./conf/flume.conf --name agent03
데이터가 이동되는 것을 볼 수 있습니다. 한가지 이슈는 exec는 파일을 읽을때 버퍼링을 좀 있다고 합니다. 파일을 수정해보면 파일 내용이 잘 전달되어 오는것을 확인 하실 수 있습니다.
 
참고

 

 

경축! 아무것도 안하여 에스천사게임즈가 새로운 모습으로 재오픈 하였습니다.
어린이용이며, 설치가 필요없는 브라우저 게임입니다.
https://s1004games.com

[출처] http://wawoops67.blogspot.kr/2013/05/flume-flume_16.html

 

 

본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
번호 제목 글쓴이 날짜 조회 수
공지 오라클 기본 샘플 데이터베이스 졸리운_곰 2014.01.02 86288
공지 [SQL컨셉] 서적 "SQL컨셉"의 샘플 데이타 베이스 SAMPLE DATABASE of ORACLE 가을의 곰을... 2013.02.10 78744
공지 [G_SQL] Sample Database 가을의 곰을... 2012.05.20 95487
18 TensorFlow Lite 101 - MoblieNet 맛보기 file 졸리운_곰 2018.05.30 1089
17 Apache MXNet에서 사전 트레이닝된 모델을 사용해 보세요. 졸리운_곰 2018.05.30 988
16 MXNet을 활용한 이미지 분류 앱 개발하기 file 졸리운_곰 2018.05.30 1424
15 세상에 있는 (거의) 모든 머신러닝 문제 공략법 file 졸리운_곰 2018.05.30 1119
14 sklearn 내부의 pickle lib 를 통해 모델을 저장하고 다시 로드하여 재사용할 수 있다. 졸리운_곰 2018.05.30 1637
13 텐서플로우 기반 딥러닝 훈련 모델 파일 저장, 로딩 및 재활용 file 졸리운_곰 2018.05.30 1766
12 TensorFlow 모델을 저장하고 불러오기 (save and restore) 졸리운_곰 2018.05.30 1638
11 텐서플로우(TensorFlow)를 이용해서 글자 생성(Text Generation) 해보기 – Recurrent Neural Networks(RNNs) 예제 – Char-RNN file 졸리운_곰 2018.05.13 1122
10 외장형 그래픽카드로 우분투에서 텐서플로우 사용 How to setup an eGPU on Ubuntu for TensorFlow file 졸리운_곰 2018.05.09 1426
9 Keras and NLTK 케라스를 이용한 NLTK 자연어처리 졸리운_곰 2018.05.08 1603
8 Windows7에서 "처음 심층 학습 프로그램」을 사경 보면 (1-2) 제 1 장 후반 file 졸리운_곰 2018.05.08 1139
7 CSLAIER CSLAIER에 의한 LSTM file 졸리운_곰 2018.05.08 1663
6 Tensorboard 사용하기 1 file 졸리운_곰 2018.05.08 1411
5 텐서보드 사용법 file 졸리운_곰 2018.05.08 1408
4 Ubuntu 18.04 Settings for TensorFlow 설치 file 졸리운_곰 2018.05.08 1181
3 딥러닝용 서버 설치기 file 졸리운_곰 2018.05.07 1392
2 Installing Tensorflow GPU on Ubuntu 18.04 LTS file 졸리운_곰 2018.05.06 1215
1 TensorFlow Lite 101 - MoblieNet 맛보기 file 졸리운_곰 2018.04.07 1273
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED