希望这可以帮助您入门。我在我的机器上测试它时遇到了一些问题,现在没有时间完全对其进行故障排除,但是我会解决的…
假设您现在已经启动并运行了Flume,这应该是您的flume.conf文件看起来像使用HTTP
POST源和本地文件接收器的样子(注意:这转到本地文件,而不是HDFS)
########## NEW AGENT ########## # flume-ng agent -f /etc/flume/conf/flume.httptest.conf -n httpagent## slagent = SysLogAgent###############################httpagent.sources = http-sourcehttpagent.sinks = local-file-sinkhttpagent.channels = ch3# Define / Configure Source (multiport seems to support newer "stuff")###############################httpagent.sources.http-source.type = org.apache.flume.source.http.HTTPSourcehttpagent.sources.http-source.channels = ch3httpagent.sources.http-source.port = 81# Local File Sink###############################httpagent.sinks.local-file-sink.type = file_rollhttpagent.sinks.local-file-sink.channel = ch3httpagent.sinks.local-file-sink.sink.directory = /root/Desktop/http_testhttpagent.sinks.local-file-sink.rollInterval = 5# Channels###############################httpagent.channels.ch3.type = memoryhttpagent.channels.ch3.capacity = 1000
用第二行上的命令启动Flume。根据您的需要进行调整(特别是port,sink.directory和rollInterval)。这是一个基本的最低配置文件,还有更多可用的选项,请查看Flume用户指南。现在,就目前而言,该代理启动并对我而言运行正常。
这是我没有时间测试的东西。默认情况下,HTTP代理接受JSON格式的数据。您应该能够通过发送带有以下形式的cURL请求来测试此代理:
curl -X POST -H 'Content-Type: application/json; charset=UTF-8' -d '{"username":"xyz","password":"123"}' http://yourdomain.com:81/-X将请求设置为POST,-H发送标头,-d发送数据(有效json),然后选择host:port。对我来说,问题是出现错误:
WARN http.HTTPSource: Received bad request from client. org.apache.flume.source.http.HTTPBadRequestException: Request has invalid JSON Syntax.
在我的Flume客户端中,无效的JSON?因此出现错误。尽管弹出错误,表明Flume源正在接收数据。无论您拥有哪种格式,只要格式有效,POST都可以正常工作。



