flume采集nginx日志文件数据到Kafka

flume官网地址http://flume.apache.org/

#下载
wget https://mirrors.bfsu.edu.cn/apache/flume/1.9.0/apache-flume-1.9.0-bin.tar.gz
#解压
tar -zxvf apache-flume-1.9.0-bin.tar.gz
#flume-env.sh中配置JAVA_HOME
cd apache-flume-1.9.0-bin/conf
cp flume-env.sh.template flume-env.sh

新建flume-conf文件,内容如下

# 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 /usr/local/nginx/logs/mylog.log

# Describe the sink
#a1.sinks.k1.type = logger
a1.sinks.k1.channel = c1
a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.kafka.topic = topic_log
a1.sinks.k1.kafka.bootstrap.servers = node01:9092,node02:9092,node03:9092,node04:9092
a1.sinks.k1.kafka.flumeBatchSize = 20
a1.sinks.k1.kafka.producer.acks = 1
a1.sinks.k1.kafka.producer.linger.ms = 1
a1.sinks.k1.kafka.producer.compression.type = snappy

# 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

启动flume

./bin/flume-ng agent --conf conf --conf-file   conf/flume-conf --name a1 -Dflume.root.logger=INFO,console

猜你喜欢

转载自blog.csdn.net/lw112190/article/details/110636006