kafka中如何创建topic?
通过如下的命令创建topic
kafka-topics.sh \ --bootstrap-server <Kafka集群地址> \ --create \ --topic <Topic名称> \ --partitions <分区数> \ --replication-factor <副本因子>
示例
bin/kafka-topics.sh \ --bootstrap-server 122.120.45.214:34991 \ --create \ --topic testtop01 \ --partitions 3 \ --replication-factor 1
创建之后,通过以下的命令查看创建好的topic
[root@nccztsjb-node-15 kafka-34991]# bin/kafka-topics.sh --bootstrap-server 122.120.45.214:34991 --describe --topic testtop01 Topic: testtop01 TopicId: EKABL7twT-CP9WL51Mjjmw PartitionCount: 3 ReplicationFactor: 1 Configs: segment.bytes=1073741824,max.message.bytes=10485760,retention.bytes=32212254720 Topic: testtop01 Partition: 0 Leader: 1 Replicas: 1 Isr: 1 Topic: testtop01 Partition: 1 Leader: 1 Replicas: 1 Isr: 1 Topic: testtop01 Partition: 2 Leader: 1 Replicas: 1 Isr: 1 [root@nccztsjb-node-15 kafka-34991]#