kafka 运维命令总结

1.kafka运行依赖zookeeper,启动zookeeper服务和kafka服务(默认单机模式,由配置文件决定):
bin/zookeeper-server-start.sh config/zookeeper.properties &
bin/kafka-server-start.sh config/server.properties &
2.创建一个主题(topic), 此主题一个备份,一个分区, 主题名为test:
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
bin/kafka-topics.sh --list --zookeeper localhost:2181 #列出所有主题
bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic test #查看主题详情
3.为主题打开一个producer,输入点信息:
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
#This is a message
#This is another message
4.打开一个consumer,会收到主题下面的信息:
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
#This is a message
#This is another message
5.查看topic
bin/kafka-topics.sh --list --zookeeper localhost:2181
6.查看kafka的topic详细信息
bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic test
7.查看消费者组
bin/kafka-consumer-groups.sh --bootstrap-server 172.1.2.3:9092,172.1.2.4:9092,172.1.2.5:9092 --list
8.查看消费者组详情
bin/kafka-consumer-groups.sh --bootstrap-server 172.1.2.3:9092,172.1.2.4:9092,172.1.2.5:9092 --group group_name1 --describe
9.查看topic信息最近5条
bin/kafka-console-consumer.sh --zookeeper emr-header-1:2181,emr-header-2:2181,emr-header-3:2181 --topic T2 --max-messages 5
10.指定消费者组消费主题数据:
bin/kafka-console-consumer.sh --bootstrap-server 172.1.2.3:9092,172.1.2.4:9092,172.1.2.5:9092 --topic T2 --group group_name1

11.查案kafka 主题数据
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic T2 --from-beginning # 若没有任何返回或没有响应,则该topic中没有数据内容;否则有

12.kafka图形化管理工具 :Kafka Manager

猜你喜欢

转载自blog.csdn.net/myy1066883508/article/details/105513500