# example.conf: A single-node Flume configuration # 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 = org.apache.flume.sink.kafka.KafkaSink a1.sinks.k1.kafka.topic = mytopic a1.sinks.k1.kafka.bootstrap.servers = server1:9092,server2:9092,server3:9092 a1.sinks.k1.kafka.flumeBatchSize = 20 # 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
bin/flume-ng agent --conf conf --conf-file conf/example.conf --name a1 -Dflume.root.logger=INFO,console
telnet localhost 44444
三个节点都开启kafka服务
bin/kafka-server-start.sh config/server.properties &
启动之后输入exit,再重新登录
exit
创建topic
bin/kafka-topics.sh --zookeeper server1:2181,server2:21821,server3:2181 --create --replication-factor 3 --partitions 1 --topic mytopic
启动消费者
bin/kafka-console-consumer.sh --zookeeper server1:2181,server2:2181,server3:2181 --from-beginning --topic mytopic
随便在telnet的窗口输入点什么,观察消费者窗口
补充命令查看所有topic
bin/kafka-topics.sh --zookeeper server3:2181 --list
删除topic
bin/kafka-topics.sh --zookeeper server1:2181 --delete --topic first
启动生产者
bin/kafka-console-producer.sh --broker-list server1:9092 --topic first
查看某个topic详情
bin/kafka-topics.sh --zookeeper hadoop102:2181 --describe --topic first
停止服务
bin/kafka-server-stop.sh stop



