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不以任何方式自动分配数据。

To add configs:

添加配置:

> bin/kafka-topics.sh --zookeeper zk_host:port/chroot --alter --topic my_topic_name --config x=y

To remove a config:

移除配置:

> bin/kafka-topics.sh --zookeeper zk_host:port/chroot --alter --topic my_topic_name --deleteConfig x

And finally deleting a topic:

最后删除主题:

> bin/kafka-topics.sh --zookeeper zk_host:port/chroot --delete --topic my_topic_name

Topic deletion option is disabled by default. To enable it set the server config

主题删除选项默认是关闭的,设置服务器配置开启它。

delete.topic.enable=true

Kafka does not currently support reducing the number of partitions for a topic or changing the replication factor.

kafka目前不支持减少分区数和改变备份数。

如果想彻底删除数据节点,可以看这篇文章 http://orchome.com/140

results matching ""

    No results matching ""