나는 Flume을 Python 스크립트로 로그를 수집하기 위해 netcat 소스로 Flume을 설정하는 사용자 가이드를 따르기 위해 telnet과 nc
테스트를 사용한다. 잘 작동한다.flume이 파이썬 소켓이나 텔넷으로 작업하는 동안 이벤트를 올바르게 가져올 수 없음
내 설정 코드 :
a1.sources = r1
a1.sinks = k1
a1.channels = c1
Describe/configure the source
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 44444
a1.sinks.k1.type = logger
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
가 그럼 난 파이썬이 수로를 연결하고 이런 식으로 몇 가지 단어를 보내는 데 사용 :
import socket
def netcat(hostname, port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((hostname, port))
s.send("test words 1\n")
s.send("test words 2\n")
s.send("test words 3\n")
s.send("test words 4\n")
s.shutdown(socket.SHUT_WR)
s.close()
if _name_ == "_main_":
netcat("127.0.0.1",44444)
문제가 발생, 수로는 2 개 행을받을 수 있습니다. 수로 로그 :
2016-12-28 16:44:32,248 (lifecycleSupervisor-1-0) [INFO - org.apache.flume.source.NetcatSource.start(NetcatSource.java:169)] Created serverSocket:sun.nio.ch.ServerSocketChannelImpl[/127.0.0.1:44444] 2016-12-28 16:44:41,814 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:95)] Event: { headers:{} body: 74 65 73 74 20 77 6F 72 64 73 20 31 test words 1 } 2016-12-28 16:44:41,815 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:95)] Event: { headers:{} body: 74 65 73 74 20 77 6F 72 64 73 20 32 test words 2 }
우분투 & Java1.8 및 CentOS의 & 자바 1.7과 파이썬에서 텔넷 모델과 같은 결과 모두에서 같은 결과를 얻었다.
config 또는 Python 스크립트에 문제가 있습니까? 아니면 누군가이 사건에 대한 조언을 받았습니까?