kafka使用
启动服务
cd /opt/kafka/bin
./kafka-server-start.sh -daemon ../config/server.properties
查看所有topic
./kafka-topics.sh --zookeeper localhost:2181 --list
./kafka-topics.sh --zookeeper localhost:2181 --list --topic demo #查看指定topic
查看指定topic
./kafka-topics.sh --zookeeper localhost:2181 --desc --topic demo
创建topic
./kafka-topics.sh --zookeeper localhost:2181 --create --topic demo --partitions 10 --replication-factor 1 # 指定副本为1。
删除topic
./kafka-topics.sh --zookeeper localhost:2181 --delete --topic demo
生产消息
./kafka-console-producer.sh --broker-list localhost:9092 --topic demo
消费消息
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic demo