Flume和kafka完成实时日志数据采集

在这里插入图片描述



agent 选型

   A机器 exec source +memory channel +avro sink

   B_1机器 avro source +memory channel +logger sink

   B_2机器 avro source +memory channel +kafka sink 


A服务器配置

exec-memory-avro.conf

# exec-memory-avro.conf: A single-node Flume configuration







# Name the components on this agent

exec-memory-avro.sources = exec-source

exec-memory-avro.sinks = avro-sink

exec-memory-avro.channels = memory-channel




# Describe/configure the source

exec-memory-avro.sources.exec-source.type = exec

exec-memory-avro.sources.exec-source.command=tail -f /data/data.log

exec-memory-avro.sources.exec-source.shell = /bin/bash -c




# Describe the sink

exec-memory-avro.sinks.avro-sink.type = avro

exec-memory-avro.sinks.avro-sink.hostname= 192.168.132.131

exec-memory-avro.sinks.avro-sink.port= 44444




# Use a channel which buffers events in memory

exec-memory-avro.channels.memory-channel.type = memory

exec-memory-avro.channels.memory-channel.capacity = 1000

exec-memory-avro.channels.memory-channel.transactionCapacity = 100







# Bind the source and sink to the channel

exec-memory-avro.sources.exec-source.channels = memory-channel

exec-memory-avro.sinks.avro-sink.channel = memory-channel




B_1服务器配置(logger输出版本)

avro-memory-logger.conf

# avro-memory-logger.conf: A single-node Flume configuration


# Name the components on this agent

avro-memory-logger.sources = avro-source

avro-memory-logger.sinks = logger-sink

avro-memory-logger.channels = memory-channel

 

# Describe/configure the source

avro-memory-logger.sources.avro-source.type = avro

avro-memory-logger.sources.avro-source.bind= 192.168.132.131

avro-memory-logger.sources.avro-source.port = 44444

 

# Describe the sink

avro-memory-logger.sinks.logger-sink.type = logger

 

# Use a channel which buffers events in memory

avro-memory-logger.channels.memory-channel.type = memory

avro-memory-logger.channels.memory-channel.capacity = 1000

avro-memory-logger.channels.memory-channel.transactionCapacity = 100


# Bind the source and sink to the channel

avro-memory-logger.sources.avro-source.channels = memory-channel

avro-memory-logger.sinks.logger-sink.channel = memory-channel



B_2服务器配置(kafka版本)

avro-memory-kafka.conf

# avro-memory-kafka.conf: A single-node Flume configuration





# Name the components on this agent

avro-memory-kafka.sources = avro-source

avro-memory-kafka.sinks = kafka-sink

avro-memory-kafka.channels = memory-channel




# Describe/configure the source

avro-memory-kafka.sources.avro-source.type = avro

avro-memory-kafka.sources.avro-source.bind = 192.168.132.131

avro-memory-kafka.sources.avro-source.port = 44444




# Describe the sink

avro-memory-kafka.sinks.kafka-sink.type = org.apache.flume.sink.kafka.KafkaSink

avro-memory-kafka.sinks.kafka-sink.brokerList = 192.168.132.131:9092

avro-memory-kafka.sinks.kafka-sink.topic = kingtest

avro-memory-kafka.sinks.kafka-sink.batchSize = 5

avro-memory-kafka.sinks.kafka-sink.requiredAcks = 1




# Use a channel which buffers events in memory

avro-memory-kafka.channels.memory-channel.type = memory




# Bind the source and sink to the channel

avro-memory-kafka.sources.avro-source.channels = memory-channel

avro-memory-kafka.sinks.kafka-sink.channel = memory-channel





启动语句

先启动B_1服务器:

flume-ng agent \

--name avro-memory-logger \

--conf $FLUME_HOME/conf \

--conf-file $FLUME_HOME/conf/avro-memory-logger.conf \

-Dflume.root.logger=INFO,console

或先启动B_2服务器:
flume-ng agent \

--name avro-memory-kafka \

--conf $FLUME_HOME/conf \

--conf-file $FLUME_HOME/conf/avro-memory-kafka.conf \

-Dflume.root.logger=INFO,console

 


然后启动A服务器:

flume-ng agent

--name exec-memory-avro \

--conf $FLUME_HOME/conf \

--conf-file $FLUME_HOME/conf/exec-memory-avro.conf \

-Dflume.root.logger=INFO,console




日志收集过程

1.机器A上监控一个文件,当我们访问主站时会有用户行为日志记录到access.log中

2.arvo sink把新产生的日志输出到对应的avro source 指定的hostname 和port 上

3.通过avro source 对应的agent将我们的日志输出到控制台/kafka
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

k5003

您的鼓励将是我创作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值