flume实例(二):监控服务器日志

1.实现功能:

监控日志增加,并且将日志信息存储到hdfs上

2.flume和hdfs集成

将hadoop对应jar包放到flume的lib目录下

htrace-core-3.1.0-incubating.jar
hadoop-hdfs-2.7.3.jar
hadoop-common-2.7.3.jar
hadoop-auth-2.7.3.jar
commons-io-2.4.jar
commons-configuration-1.6.jar

3.配置文件

#a1是代理
# 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  /var/log/httpd/access_log
a1.sources.r1.channels = c1

# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100


# Describe the sink
a1.sinks.k1.type=hdfs
a1.sinks.k1.hdfs.path=hdfs://bigdata.ibeifeng.com:8020/flume02
a1.sinks.k1.channel = c1

4.启动命令

(1)启动hdfs

(2)启动flume

bin/flume-ng agent --name a1  --conf conf  --conf-file conf/apache-sink-hdfs.conf 

 

你可能感兴趣的:(大数据开发,flume)