Him*_*shu 12 java hadoop flume
我是Flume和Hadoop的新手.我们正在开发一个BI模块,我们可以在HDFS中存储来自不同服务器的所有日志.
为此,我使用Flume.我刚刚开始尝试.成功创建了一个节点,但现在我愿意设置一个HTTP源和一个接收器,它将通过HTTP将传入的请求写入本地文件.
任何建议?
提前致谢/
Bea*_*ing 13
希望这有助于您入门.我有一些问题,我的机器上测试这一点,并没有时间到现在完全解决它,但我会去那...
假设你已经水槽了,现在运行的权利,这应该是你的flume.conf文件需要看起来像使用一个HTTP POST源和本地文件接收器(注:这都到了本地文件,不HDFS)是什么
########## NEW AGENT ##########
# flume-ng agent -f /etc/flume/conf/flume.httptest.conf -n httpagent
#
# slagent = SysLogAgent
###############################
httpagent.sources = http-source
httpagent.sinks = local-file-sink
httpagent.channels = ch3
# Define / Configure Source (multiport seems to support newer "stuff")
###############################
httpagent.sources.http-source.type = org.apache.flume.source.http.HTTPSource
httpagent.sources.http-source.channels = ch3
httpagent.sources.http-source.port = 81
# Local File Sink
###############################
httpagent.sinks.local-file-sink.type = file_roll
httpagent.sinks.local-file-sink.channel = ch3
httpagent.sinks.local-file-sink.sink.directory = /root/Desktop/http_test
httpagent.sinks.local-file-sink.rollInterval = 5
# Channels
###############################
httpagent.channels.ch3.type = memory
httpagent.channels.ch3.capacity = 1000
Run Code Online (Sandbox Code Playgroud)
使用第二行上的命令启动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/
Run Code Online (Sandbox Code Playgroud)
-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.
Run Code Online (Sandbox Code Playgroud)
在我的Flume客户端,无效的JSON?所以有些东西被送错了.虽然弹出错误的事实表明Flume源正在接收数据.无论你拥有什么,POST都应该有效,只要它是有效的格式.
| 归档时间: |
|
| 查看次数: |
13877 次 |
| 最近记录: |