Flume-NG

  • Apache 메인프로젝트로 승격되고, 1.1.0 부터는 Flume NG라는 이름으로 부르고 있습니다.
  • Flume NG는 FLUME-728 이슈에 따라 Flume을 리팩토링한 프로젝트로 코드명 Flume NG로 배포되고 있습니다.

개요

  • agent :
  • channel :
  • source : 논리노드가 수집할 데이터에 대한 설정
  • sink : 수집한 데이터를 전송할 대상에 대한 설정

설치하기

설치

  • 다운로드 및 압축해제

 wget http://apache.tt.co.kr/flume/1.2.0/apache-flume-1.2.0-bin.tar.gz
 tar -xvf apache-flume-1.2.0.tar.gz

  • 환경변수 설정

export FLUME_HOME=/apps/apache-flume-1.2.0
PATH=$PATH:$HOME/bin:${FLUME_HOME}/bin
export PATH

Flume 설치 테스트

  • Flume이 정상적으로 설치 되었는지 아래와 같이 테스트 해보자
example.conf 파일 생성(Collector 서버)
  • single-node Flume configuration 예

conf/example.conf



# agent 설정
collector_agent.sources = source1
collector_agent.sinks = sink1
collector_agent.channels = channel1

# sources 설정
collector_agent.sources.source1.type = netcat
collector_agent.sources.source1.bind = 10.101.25.173 
collector_agent.sources.source1.port = 8994

# sinks 설정
collector_agent.sinks.sink1.type = logger

# channel 설정
collector_agent.channels.channel1.type = memory
collector_agent.channels.channel1.capacity = 1000
collector_agent.channels.channel1.transactionCapactiy = 100

# channel에 sources와 sinks 바인딩
collector_agent.sources.source1.channels = channel1
collector_agent.sinks.sink1.channel = channel1

collector_agent 실행 (Collector 서버)
  • flume-ng로 collector_agent를 실행한다.

bin/flume-ng agent --conf-file conf/example.conf --name collector_agent -Dflume.root.logger=INFO,console

로그 전송(로그전송 서버)
  • 로그 전송 서버에서 telnet으로 접속해서 로그를 찍어보자

# telnet 접속 
 telnet 10.101.25.173 8994
 
# Connected 후 메세지를 전송한다. 
Connected to 10.101.25.173 (10.101.25.173).
Escape character is '^]'.
Hello World!!    
OK
Yes..OK!!
OK


  • Collector서버에 정상적으로 전송되는 것을 확인할 수 있다.

 12/09/19 10:19:57 INFO source.NetcatSource: Source starting
12/09/19 10:19:57 INFO source.NetcatSource: Created serverSocket:sun.nio.ch.ServerSocketChannelImpl[/10.101.25.173:8994]
12/09/19 10:20:12 INFO sink.LoggerSink: Event: { headers:{} body: 48 65 6C 6C 6F 20 57 6F 72 6C 64 21 21 0D       Hello World!!. }
 

Configuration

Flume Sources

  • Avro Source : Listens on Avro port and receives events from external Avro client streams.
  • Exec Source : Exec source runs a given Unix command on start-up and expects that process to continuously produce data on standard out
  • NetCat Source : A netcat-like source that listens on a given port and turns each line of text into an event.

Apache access log 전송 설정

  • Collector 서버와 Apache access log 전송서버 모두 동일한 디렉토리에 apache-flume-1.2.0를 설치하였다.

Collector 서버 설정

  • 수집서버 agent 환경 설정
  • conf/flume-conf.properties

conf/flume-conf.properties


# agent 설정
collector_agent.sources = avro-source
collector_agent.sinks = fileSink
collector_agent.channels = channel1

# channel 설정
collector_agent.channels.channel1.type = memory
collector_agent.channels.channel1.capacity = 1000
collector_agent.channels.channel1.transactionCapactiy = 100

# sources 설정
collector_agent.sources.avro-source.type = avro
collector_agent.sources.avro-source.bind = 10.101.25.173
collector_agent.sources.avro-source.port = 8994

# sinks 설정
collector_agent.sinks.fileSink.type = FILE_ROLL
collector_agent.sinks.fileSink.sink.directory = /apps/apache-flume-1.2.0/data
# rollInterval단위는 seconds
collector_agent.sinks.fileSink.sink.rollInterval = 3600

# channel에 sources와 sinks 바인딩
collector_agent.sources.avro-source.channels = channel1
collector_agent.sinks.fileSink.channel = channel1


  • 수집서버 agent 실행

bin/flume-ng agent -n collector_agent --conf ./conf/ -f conf/flume-conf.properties &

Apache access log 전송서버 설정

  • Apache access log 전송서버 환경 설정
  • conf/flume-transfer-conf.properties

conf/flume-transfer-conf.properties


# agent 설정 
agent_transfer.channels = channel1
agent_transfer.sources = reader
agent_transfer.sinks = avro-forward-sink

# channel 설정
agent_transfer.channels.channel1.type = memory
agent_transfer.channels.channel1.capacity = 1000000
agent_transfer.channels.channel1.transactionCapacity = 10000

# sources 설정
agent_transfer.sources.reader.type = exec
#agent_transfer.sources.reader.command = tail -F /logs/apache/access.log.`/bin/date +%Y%m%d`
agent_transfer.sources.reader.command = tail -F /logs/apache/access.log.20120919
agent_transfer.sources.reader.logStdErr = true
agent_transfer.sources.reader.restart = true

# sinks 설정
agent_transfer.sinks.avro-forward-sink.type = avro
agent_transfer.sinks.avro-forward-sink.hostname =10.101.25.173 
agent_transfer.sinks.avro-forward-sink.port = 8994
agent_transfer.sinks.avro-forward-sink.batch-size = 100
agent_transfer.sinks.avro-forward-sink.runner.type = polling
agent_transfer.sinks.avro-forward-sink.runner.polling.interval = 10

# channel에 sources와 sinks 바인딩
agent_transfer.sources.reader.channels = channel1
agent_transfer.sinks.avro-forward-sink.channel = channel1


  • Apache access log 전송서버 agent 실행
 
bin/flume-ng agent -n agent_transfer --conf ./conf/ -f conf/flume-transfer-conf.properties &

참고자료