2-Flume上传

Flume监听Nginx日志

要求:
1. 日志文件每十分钟生成一次,日志内容达到 1M 时也生成一次
2. HDFS上的日志文件名称为:nginx_%Mxxx.log,%M 为分钟,如: nginx_10.1472888328817.log。

# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /opt/datas/nginx/user_logs/access.log
a1.sources.r1.channels = c1

# Describe the sink
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = hdfs://bigdata.liangxw.com:9000/user/liangxw/nginx/logs/%Y/%m/%d
 # set prefix, including %M
a1.sinks.k1.hdfs.filePrefix=nginx_%M
a1.sinks.k1.hdfs.fileSuffix=.log
a1.sinks.k1.hdfs.useLocalTimeStamp = true
a1.sinks.k1.hdfs.fileType = DataStream
 # every 10 minutes
a1.sinks.k1.hdfs.round = true
a1.sinks.k1.hdfs.roundValue = 10
a1.sinks.k1.hdfs.roundUnit = minute
a1.sinks.k1.hdfs.rollInterval = 0
 # every 1m
 # 1M=1024*1024Byte=1048576Byte
a1.sinks.k1.hdfs.rollSize = 1048576
a1.sinks.k1.hdfs.rollCount = 0
a1.sinks.k1.hdfs.idleTimeout=10

# 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 = c1
a1.sinks.k1.channel = c1

上传结果


2-Flume上传_第1张图片
上传结果.png

你可能感兴趣的:(2-Flume上传)