Flume安装配置
1、上传安装包,解压
2、修改配置文件
cd /root/apps/apache-flume-1.6.0-bin/conf
cp flume-env.sh.template ./flume-env.sh
vi flume-env.sh
只用修改JAVA_HOME=jdk目录
可以输入命令:
:r! echo /root/apps/jdk1.8.0_60
3、在apache-flume-1.6.0-bin目录下,建文件夹myconf,在myconf中创建文件netcat-console.conf,并写入以下内容
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = netcat
a1.sources.r1.bind = 192.168.139.11
a1.sources.r1.port = 44444
# Describe the sink
a1.sinks.k1.type = logger
# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
a1.sources.r1.channels = c1a1.sinks.k1.channel = c1
4、启动命令
bin/flume-ng agent -n a1 -c conf/ -f ./myconf/netcat-console.conf -Dflume.root.logger=INFO,console
5、访问命令
telnet localhost 44444
常见错误:
Flume采集数据到HDFS时,生成的文件中,开头信息有乱码:
翻看Flume文档,发现,HdfsEventSink中,hdfs.fileType默认为SequenceFile,将其改为DataStream就可以按照采集的文件原样输入到hdfs,加以下配置
a1.sinks.k1.hdfs.fileType=DataStream
用Kafka做channel的时候,运行消费者报错: 加以下配置,不让channel作为Event对象解析
a1.channels.c1.parseAsFlumeEvent=false