[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 86308
공지 [SQL컨셉] 서적 "SQL컨셉"의 샘플 데이타 베이스 SAMPLE DATABASE of ORACLE 가을의 곰을... 2013.02.10 78761
공지 [G_SQL] Sample Database 가을의 곰을... 2012.05.20 95508
15 [표준SQL] 퀴즈로 배우는 SQL : 전기 요금 계산 file 졸리운_곰 2024.08.10 1576
14 [표준SQL] 퀴즈로 배우는 SQL : 파이프 연결하기 file 졸리운_곰 2024.08.10 1320
13 [표준SQL] 퀴즈로 배우는 SQL : 공통점이 가장 많은 친구 찾기 file 졸리운_곰 2024.08.10 2117
12 [표준 SQL] 퀴즈로 배우는 SQL : 일별 누적 접속자 통계 구하기 file 졸리운_곰 2024.08.10 1685
11 [표준 SQL] 퀴즈로 배우는 SQL : 구분자로 나누어 행,열 바꾸기 file 졸리운_곰 2024.08.10 1884
10 [표준 SQL] 퀴즈로 배우는 SQL : 신입사원 부서 배치에 따른 급여 랭킹 시뮬레이션 file 졸리운_곰 2024.08.10 1340
9 [표준 SQL] 퀴즈로 배우는 SQL : 시작일, 종료일 사이의 휴일을 제외한 일수 구하기 file 졸리운_곰 2024.08.10 1479
8 [표준 SQL] 권순용의 DB 이야기 : 함수 기반 인덱스의 개념과 생성 이해 file 졸리운_곰 2024.08.10 1374
7 [표준 SQL] 퀴즈로 배우는 SQL : 계층 쿼리를 이용해 조직도 만들기 file 졸리운_곰 2024.08.10 2069
6 [표준 SQL] SQL을 잘한다는 기준은 무엇일까 file 졸리운_곰 2024.08.10 1340
5 [SQL] CRUD 기본 사용법 file 졸리운_곰 2023.01.23 1393
4 [기본 SQL] SELECT, INSERT, UPDATE, DELETE file 졸리운_곰 2022.04.26 1209
3 Mysql Join 해부(Left, Right, Outer, Inner Join) file 졸리운_곰 2019.01.30 1578
2 Join의 모든것.(LEFT OUTER, RIGHT OUTER, INNER, FULL OUTER, CROSS) 졸리운_곰 2019.01.30 1518
1 SELECT 문법 file 졸리운_곰 2017.11.22 2314
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED