Kafka簡單使用
啟動(dòng)zookeeper
> bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
啟動(dòng)Kafka Server
> bin/kafka-server-start.sh config/server.properties
Topic相關(guān)
創(chuàng)建Topic
新版命令:
> bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic [topic-name]
查看所有topic列表
> bin/kafka-topics.sh --list --bootstrap-server localhost:9092
查看某個(gè)topic的信息
> bin/kafka-topics.sh --describe --bootstrap-server localhost:9092 --topic [topic-name]
修改某個(gè)topic的partition個(gè)數(shù)(分區(qū)數(shù)只能增不能減)
> bin/kafka-topics.sh --bootstrap-server localhost:2181 --alter --topic [topic-name] --partitions [new-partitions-count]
eg: > bin/kafka-topics.sh --bootstrap-server localhost:2181 --alter --topic topic-test --partitions 10
Producer相關(guān)
Producer生產(chǎn)消息
> bin/kafka-console-producer.sh --broker-list localhost:9092 --topic [topic-name]
Consumer相關(guān)
查看所有消費(fèi)者組
> bin/kafka-consumer-groups --bootstrap-server localhost:9092 --list
查看指定group(group01)的消費(fèi)情況
> bin/kafka-consumer-groups --describe --group group01 --bootstrap-server localhost:9092
Consumer消費(fèi)消息
> bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic [topic-name]

浙公網(wǎng)安備 33010602011771號(hào)