900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > Topic 相关操作(创建 查看 修改 删除)

Topic 相关操作(创建 查看 修改 删除)

时间:2023-01-18 08:39:38

相关推荐

Topic 相关操作(创建 查看 修改 删除)

创建 topic

[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.

查看 topic

[root@localhost kafka_2.12-2.2.1]# bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic heilu // 查看topic详细信息Topic:heiluPartitionCount:2ReplicationFactor:1Configs:Topic: heiluPartition: 0Leader: 0Replicas: 0Isr: 0Topic: heiluPartition: 1Leader: 0Replicas: 0Isr: 0

修改 topic

[root@localhost kafka_2.12-2.2.1]# bin/kafka-topics.sh --alter --zookeeper 192.168.131.130:2181 --topic heilu --config flush.messages=1WARNING: Altering topic configuration from this script has been deprecated and may be removed in future releases.Going forward, please use kafka-configs.sh for this functionalityUpdated config for topic heilu.

删除 topic

若 delete.topic.enable=true,直接彻底删除topic。

若 delete.topic.enable=false,如果当前topic没有使用过即没有传输过信息,可以彻底删除。

如果当前topic有使用过即有传输过信息,并没有真正删除topic,只是标记为删除(marked for deletion),重启kafka server 后删除。

[root@localhost kafka_2.12-2.2.1]# bin/kafka-topics.sh --delete --zookeeper 192.168.131.130:2181 --topic heilu // 删除命令Topic heilu is marked for deletion. // 结果是 标记为删除Note: This will have no impact if delete.topic.enable is not set to true.[root@localhost kafka_2.12-2.2.1]#

添加 partitions

只能添加,不能减少

[root@localhost kafka_2.12-2.2.1]# bin/kafka-topics.sh --alter --zookeeper 192.168.131.130:2181 --topic heilu --partitions 3WARNING: If partitions are increased for a topic that has a key, the partition logic or ordering of the messages will be affectedAdding partitions succeeded!

查看所有topic

[root@localhost kafka_2.12-2.2.1]# bin/kafka-topics.sh --zookeeper localhost:2181 --list // 查看存在 topic 命令 heilu

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。