命令总结"/>
Kafka 命令总结
//列出所有的topic
kafka-topics --zookeeper localhost:2181 --list
//查看指定topic的分区、副本情况
kafka-topics --zookeeper localhost:2181 --topic test_topic --describe
//消费某个topic,可以从头消费,也可以指定分区或带过滤条件消费
kafka-console-consumer --bootstrap-server localhost:9092 --topic test_topic --from-beginning
kafka-console-consumer --bootstrap-server localhost:9092 --topic test_topic --partition 2 | grep "test"
//在某个topic生成数据
kafka-console-producer --broker-list localhost:9092 --topic test_topic
//创建topic,可以设定分区、副本,也可以配置一些内容
kafka-topics --create --zookeeper localhost:2181 --replication-factor 2 --partitions 2 --topic test_topic --config message.timestamp.type=CreateTime
//修改某个topic的分区数或配置信息
kafka-topics --alter --zookeeper localhost:2181 --topic test_topic --partitions 4
kafka-topics --zookeeper localhost:2181 --alter --topic test_topic --config max.partition.fetch.bytes=5252880
//删除某个topic
kafka-topics --zookeeper localhost:2181 --delete --topic test_topic
//获取Kafka每个分区最新Offset的几种方法
kafka-run-class kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic test_topic
//消费组
kafka-consumer-groups --bootstrap-server localhost:9092 --list //列出当前集群中所有的消费组名称
kafka-consumer-groups --bootstrap-server localhost:9092 --group test_group --describe //展示消费组test_group的详细信息
kafka-consumer-groups --bootstrap-server localhost:9092 --describe --group test_group --state //展示消费组test_group状态
kafka-consumer-groups --bootstrap-server localhost:9092 --describe --group test_group --members --verbose//展示消费组test_group成员
kafka-consumer-groups --bootstrap-server localhost:9092 --group test_group --delete//删除消费组test_group
更多推荐
Kafka 命令总结
发布评论