人生到头来,就是不断放下,但永远最令人心痛|

durtime

园龄:4年8个月粉丝:10关注:1

kafka+flume使用

启动zookeeper

zkServer.sh start

1、创建topic
./bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --topic topic1 --partitions 1 --replication-factor 1

2、监控topic
./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic topic1

3、根据配置启动flume,后在kafka消费,telnet localhost 44444 发送信息
./bin/flume-ng agent -c conf/ -f /opt/module/apache-flume-1.9.0-bin/conf/netc.conf -n a1 -Dflume.root.logger=INFO,console

命令解析
--conf conf:配置文件目录
--conf-file jobs/t1/flume-telnet-logger.conf:flume本次启动读取的配置文件位置
--name a1:agent的名字
-Dflume.root.logger==INFO,console
-D表示flume运行时动态修改flume.root.logger参数属性值
将控制台日志打印级别设置为INFO级别


4、配置
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source 源头
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 44444

# Describe the sink 目的地
# a1.sinks.k1.type = logger
a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.topic = topic1
a1.sinks.k1.kafka.bootstrap.servers = localhost:9092
a1.sinks.k1.serializer.class = kafka.serializer.StringEncoder

# 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

本文作者:durtime

本文链接:https://www.cnblogs.com/durtime/p/16695860.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   durtime  阅读(44)  评论(0编辑  收藏  举报
历史上的今天:
2021-09-15 springboot返回值处理器
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
展开