创建topic命令:
[root@localhost kafka_2.12-2.2.1]# ls
bin config libs LICENSE logs NOTICE site-docs
[root@localhost kafka_2.12-2.2.1]# bin/kafka-topics.sh --zookeeper localhost:2181 --create --topic heilu --partitions 2 --replication-factor 1 // 创建 topic 命令
Created topic heilu.
[root@localhost kafka_2.12-2.2.1]# bin/kafka-topics.sh --zookeeper localhost:2181 --list // 查看存在 topic 命令
heilu
[root@localhost kafka_2.12-2.2.1]# bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic heilu // 查看topic详细信息
Topic:heilu PartitionCount:2 ReplicationFactor:1 Configs:
Topic: heilu Partition: 0 Leader: 0 Replicas: 0 Isr: 0
Topic: heilu Partition: 1 Leader: 0 Replicas: 0 Isr: 0
[root@localhost kafka_2.12-2.2.1]#
解释:
--zookeeper: 指定了kafka所连接的zookeeper服务地址
--toipic: 指定了所要创建的主题的名称
--partitions: 指定了分区个数
--replication-factor: 指定了副本因子
--create: 创建主题的动作指令