본문 바로가기
Data Base/Hadoop

[Hadoop] : 웹 서버 배포(3부)

by 오주현 2021. 11. 18.
반응형
데이터 수집 환경설정

Flume에서 자주 사용되는 예제입니다.

 

vi로 flume-netcat을 만들어 줍니다.

 

# The configuration file needs to define the sources,
# ths channels and the sinks.
# Sources, chnnels and sinks are defined per agent,
# in this case called 'agent'

agent.sources = s1
agent.channels = c1
agent.sinks = k1

agent.sources.s1.type = netcat
agent.sources.s1.bind = localhost
agent.sources.s1.port = 10001
agent.sources.s1.channels = c1

agent.sinks.k1.type = logger
agent.sinks.k1.channel = c1

agent.channels.c1.type = memory

안에 코드를 작성해 줍니다. 

Source = 수집

 

agent.sources.s1.type = netcat
agent.sources.s1.bind = localhost
agent.sources.s1.port = 10001
agent.sources.s1.channels = c1

10001번 포트로 들어오는 요청에 대해 로그를 찍어줍니다.

 

agent.sinks.k1.type = logger
agent.sinks.k1.channel = c1

수집된 정보를 보여주는 방법을 로깅으로 보여줍니다.

 

정상적으로 파일이 생성되어 있습니다.

 

데이터수집 환경 실행

bin/flume-ng agent -c conf/ --conf-file conf/flume-netcat -n agent -Dflume.root.logger=INFO,console

실행 명령어를 입력해 줍니다.

정상적으로 실행이 되고 있습니다.

이제 푸티 창을 하나 더 켜줍니다.

 

netstat -ntlp

명령어를 통해 플룸이 사용하는 포트를 확인해 줍니다.

10001번 포트가 정상적으로 실행되고 있습니다.

 

telnet localhost 10001

telnet을 통해 플룸에 접속해 줍니다.

 

telnet으로 접속한 곳에서 메시지를 입력하니 로그창에 메시지가 정상적으로 찍히는 것을 볼 수 있습니다.

반응형

댓글