You can change the configuration or partitioning of a topic using the same topic tool.
你可以使用同样的topic工具更改topic的配置和分区。
To add partitions you can do
你可以添加分区
> bin/kafka-topics.sh --zookeeper zk_host:port/chroot --alter --topic my_topic_name
--partitions 40
Be aware that one use case for partitions is to semantically partition data, and adding partitions doesn't change the partitioning of existing data so this may disturb consumers if they rely on that partition. That is if data is partitioned byhash(key) % number_of_partitionsthen this partitioning will potentially be shuffled by adding partitions but Kafka will not attempt to automatically redistribute data in any way.
要知道,一个用例的分区是语义上的分区数据,添加分区不能改变现有的数据,如果分区被使用中,这就可能会扰乱消费者。也就是说如果数据通过哈希(key)number_of_partitions划分,那么该分区将通过添加分区进行洗牌,但kafka不以任何方式自动分配数据。
T