Flume实战案例之整合Kafka实现日志采集

目标

将A服务器上的日志实时采集到B服务器

技术选型

在这里插入图片描述

版本说明

flume:apache-flume-1.6.0-cdh5.15.1-bin
kafka:kafka_2.11-0.9.0.0

配置文件

A服务器Flume配置文件:exec_memory_avro.conf

exec_memory_avro.sources = exec_source
exec_memory_avro.sinks = avro_sink
exec_memory_avro.channels = memory_channel

exec_memory_avro.sources.exec_source.type = exec
exec_memory_avro.sources.exec_source.command = tail -F /data/log/access_10000.log
exec_memory_avro.sources.exec_source.shell = /bin/sh -c

exec_memory_avro.sinks.avro_sink.type = avro
exec_memory_avro.sinks.avro_sink.hostname = hlsijx
exec_memory_avro.sinks.avro_sink.port = 44444

exec_memory_avro.channels.memory_channel.type = memory

exec_memory_avro.sources.exec_source.channels = memory_channel
exec_memory_avro.sinks.avro_sink.channel = memory_channel

B服务器Flume配置文件:avro_memory_kafka.conf

avro_memory_kafka.sources = avro_source
avro_memory_kafka.sinks = kafka_sink
avro_memory_kafka.channels = memory_channel

avro_memory_kafka.sources.avro_source.type = avro
avro_memory_kafka.sources.avro_source.bind = hlsijx
avro_memory_kafka.sources.avro_source.port = 44444

avro_memory_kafka.sinks.kafka_sink.type = org.apache.flume.sink.kafka.KafkaSink
avro_memory_kafka.sinks.kafka_sink.kafka.bootstrap.servers = hlsijx:9092
avro_memory_kafka.sinks.kafka_sink.kafka.topic = hello-spark
avro_memory_kafka.sinks.kafka_sink.flumeBatchSize = 3

avro_memory_kafka.channels.memory_channel.type = memory

avro_memory_kafka.sources.avro_source.channels = memory_channel
avro_memory_kafka.sinks.kafka_sink.channel = memory_channel

测试

1、启动B服务器的Agent(必须先启动B,因为要监听44444端口)

flume-ng agent \
--conf $FLUME_HOME/conf \
--conf-file $FLUME_HOME/conf/avro_memory_kafka.conf \
--name avro_memory_kafka \
-Dflume.root.logger=INFO,console

2、启动A服务器的Agent

flume-ng agent \
--conf $FLUME_HOME/conf \
--conf-file $FLUME_HOME/conf/exec_memory_avro.conf \
--name exec_memory_avro \
-Dflume.root.logger=INFO,console

3、新开一个窗户输入echo hello flume >> access_10000.log,同时启动flume和kafka在服务器B就能看到消费结果。

kafka1.6文档

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值