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 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
2021-09-15 springboot返回值处理器