一、如何使用flume
在CDH界面添加服务,选择flume之后选择主机,flume服务就启动了,下面就是配置参数
二、关于配置文件
有些网友在配置flume的时候,配置文件保存正常没有报错,但是hdfs上就没有数据,
host = hadoop05.test
service_name = flume
service_version = 5
service_release = 5.5.1
role_name = flume-AGENT-b0f62894530a4576a0548de37a772fa7
collect_interval = 60
log_dir = /var/log/flume-ng
flume_http_port = 41414
agent_name = tier1
flume.conf配置文件
tier1.sources=r1
tier1.sinks=k1
tier1.channels=c1
tier1.sources.r1.type=spooldir
tier1.sources.r1.spoolDir=/var/lib/hadoop-hdfs/logs
tier1.sources.r1.channels=c1
tier1.sources.r1.fileHeader=false
tier1.sinks.k1.type=hdfs
tier1.sinks.k1.hdfs.path=hdfs://nameservice1/user/hdfs/logs
tier1.sinks.k1.hdfs.fileType=DataStream
tier1.sinks.k1.hdfs.writeFormat=TEXT
tier1.sinks.k1.hdfs.rollInterval=60
tier1.sinks.k1.channel=c1
tier1.channels.c1.type=file
tier1.channels.c1.checkpointDir=./file_channel/checkpoint
在CDH界面添加服务,选择flume之后选择主机,flume服务就启动了,下面就是配置参数
二、关于配置文件
有些网友在配置flume的时候,配置文件保存正常没有报错,但是hdfs上就没有数据,
原因是因为,CDH的 cloudera-monitor.properties里配置agent_name,所以我们配置的时候需要使用这个名字,
cloudera-monitor.properties文件内容
host = hadoop05.test
service_name = flume
service_version = 5
service_release = 5.5.1
role_name = flume-AGENT-b0f62894530a4576a0548de37a772fa7
collect_interval = 60
log_dir = /var/log/flume-ng
flume_http_port = 41414
agent_name = tier1
flume.conf配置文件
tier1.sources=r1
tier1.sinks=k1
tier1.channels=c1
tier1.sources.r1.type=spooldir
tier1.sources.r1.spoolDir=/var/lib/hadoop-hdfs/logs
tier1.sources.r1.channels=c1
tier1.sources.r1.fileHeader=false
tier1.sinks.k1.type=hdfs
tier1.sinks.k1.hdfs.path=hdfs://nameservice1/user/hdfs/logs
tier1.sinks.k1.hdfs.fileType=DataStream
tier1.sinks.k1.hdfs.writeFormat=TEXT
tier1.sinks.k1.hdfs.rollInterval=60
tier1.sinks.k1.channel=c1
tier1.channels.c1.type=file
tier1.channels.c1.checkpointDir=./file_channel/checkpoint
tier1.channels.c1.dataDirs=./file_channel/data
三、flume二次开发
根据自己的业务需求,收集日志文件,还可以自己开发修改flume的源代码,满足自己的需求。
二次开发参考:https://github.com/huyanping/flume-sinks-safe-roll-file-sink