创建topic:
[root@zookeep-kafka-node1 bin]# ./kafka-topics.sh --create --zookeeper 10.23.209.70:2181,10.23.209.71:2181,10.23.209.72:2181 --replication-factor 3 --partitions 3 --topic test Created topic test.
显示topic:
[root@zookeep-kafka-node1 bin]# ./kafka-topics.sh --describe --zookeeper 10.23.209.70:2181,10.23.209.71:2181,10.23.209.72:2181 --topic test Topic:test PartitionCount:3 ReplicationFactor:3 Configs: Topic: test Partition: 0 Leader: 70 Replicas: 70,72,71 Isr: 70,72,71 Topic: test Partition: 1 Leader: 71 Replicas: 71,70,72 Isr: 71,70,72 Topic: test Partition: 2 Leader: 72 Replicas: 72,71,70 Isr: 72
列出topic:
[root@zookeep-kafka-node1 bin]# ./kafka-topics.sh --list --zookeeper 10.23.209.70:2181,10.23.209.71:2181,10.23.209.72:2181 test
创建生产者
[root@zookeep-kafka-node1 bin]# ./kafka-console-producer.sh --broker-list 10.23.209.70:9092 -topic test >hello >1 >2 >3
创建消费者
[root@zookeep-kafka-node2 bin]# ./kafka-console-consumer.sh --bootstrap-server 10.23.209.71:9092 -topic test hello 1 2 3
删除topic
[root@zookeep-kafka-node1 bin]# ./kafka-topics.sh --delete --zookeeper 10.23.209.70:2181,10.23.209.71:2181,10.23.209.72:2181 --topic test
查看消费组
[root@zookeep-kafka-node1 kafka_2.12-2.3.0]# bin/kafka-consumer-groups.sh --all-groups --bootstrap-server 10.23.209.71:9092 --list console-consumer-96253 console-consumer-86669
查看组信息
[root@zookeep-kafka-node1 kafka_2.12-2.3.0]# bin/kafka-consumer-groups.sh --bootstrap-server 10.23.209.71:9092 --group console-consumer-86669 --describe GROUP TOPIC PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG CONSUMER-ID HOST CLIENT-ID console-consumer-86669 test 0 51 51 0 consumer-1-636102e9-321f-4537-ac28-7a341a77c10f /10.23.209.72 consumer-1 console-consumer-86669 test 1 51 51 0 consumer-1-636102e9-321f-4537-ac28-7a341a77c10f /10.23.209.72 consumer-1 console-consumer-86669 test 2 51 51 0 consumer-1-636102e9-321f-4537-ac28-7a341a77c10f /10.23.209.72 consumer-1