Kafka 常用命令

1創建一個Topic

bin/kafka-topics.sh --create --zookeeper slave2:2181,slave3:2181,slave4:2181 --replication-factor 1 --partitions 5 --topic test --config delete.retention.ms=172800000

2刪除一個Topic(默認情況只是給topic打個標記)

bin/kafka-topics.sh --zookeeper slave:2181,slave2:2181,slave32181  --delete --topic "test"

3查看所有topic

bin/kafka-topics.sh --zookeeper slave2:2181 --list

[root@apps kafka]# bin/kafka-topics.sh --zookeeper slave2:2181 --list
__consumer_offsets
test - marked for deletion
test1
[root@apps kafka]# 

4查看指定topic

[root@apps kafka]# bin/kafka-topics.sh --zookeeper slave2:2181,slave3:2181,slave4:2181 --topic test1 --describe
Topic:test1	PartitionCount:5	ReplicationFactor:1	Configs:delete.retention.ms=172800000
	Topic: test1	Partition: 0	Leader: 0	Replicas: 0	Isr: 0
	Topic: test1	Partition: 1	Leader: 0	Replicas: 0	Isr: 0
	Topic: test1	Partition: 2	Leader: 0	Replicas: 0	Isr: 0
	Topic: test1	Partition: 3	Leader: 0	Replicas: 0	Isr: 0
	Topic: test1	Partition: 4	Leader: 0	Replicas: 0	Isr: 0
[root@apps kafka]# 

5生產者

bin/kafka-console-producer.sh --broker-list apps:9092 --topic test1

6消費者

bin/kafka-console-consumer.sh --bootstrap-server apps:9092 --topic test1 --from-beginning

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章