阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Flume采集Nginx日志到HDFS

135次阅读
没有评论

共计 1319 个字符,预计需要花费 4 分钟才能阅读完成。

Flume 采集 Nginx 日志到 HDFS

下载 apache-flume-1.7.0-bin.tar.gz,用

tar -zxvf

解压,在 /etc/profile 文件中增加设置:

export FLUME_HOME=/opt/apache-flume-1.7.0-bin
export PATH=$PATH:$FLUME_HOME/bin

修改 $FLUME_HOME/conf/ 下的两个文件,在 flume-env.sh 中增加 JAVA_HOME:

JAVA_HOME=/opt/jdk1.8.0_121

最重要的,修改 flume-conf.properties 文件:

# 配置 Agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# 配置 Source
a1.sources.r1.type = exec
a1.sources.r1.channels = c1
a1.sources.r1.deserializer.outputCharset = UTF-8

# 配置需要监控的日志输出目录
a1.sources.r1.command = tail -F /usr/local/nginx/log/access.log

# 配置 Sink
a1.sinks.k1.type = hdfs
a1.sinks.k1.channel = c1
a1.sinks.k1.hdfs.useLocalTimeStamp = true
a1.sinks.k1.hdfs.path = hdfs://master:9000/flume/events/%Y-%m
a1.sinks.k1.hdfs.filePrefix = %Y-%m-%d-%H
a1.sinks.k1.hdfs.fileSuffix = .log
a1.sinks.k1.hdfs.minBlockReplicas = 1
a1.sinks.k1.hdfs.fileType = DataStream
a1.sinks.k1.hdfs.writeFormat = Text
a1.sinks.k1.hdfs.rollInterval = 86400
a1.sinks.k1.hdfs.rollSize = 1000000
a1.sinks.k1.hdfs.rollCount = 10000
a1.sinks.k1.hdfs.idleTimeout = 0

# 配置 Channel
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

# 将三者连接
a1.sources.r1.channel = c1
a1.sinks.k1.channel = c1

以上文件设置了 Source、Channel 和 Sink,将 Nginx 日志中的记录采集到 HDFS,运行

flume-ng agent -n a1 -c conf -f $FLUME_HOME/conf/flume-conf.properties

如果没有报错,则安装设置成功了,Nginx 中新增加的记录都会被 Flume 采集,并且存储到 HDFS。

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-06/144600.htm

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-21发表,共计1319字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中