半兽人 发表于: 2015-03-10   最后更新时间: 2019-01-12  
You have the option of either adding topics manually or having them be created automatically when data is first published to a non-existent topic. If topics are auto-created then you may want to tune the default topic configurations used for auto-created topics.

Topics are added and modified using the topic tool:

 > bin/kafka-topics.sh --zookeeper zk_host:port/chroot --create --topic my_topic_name 
       --partitions 20 --replication-factor 3 --config x=y
The replication factor controls how many servers will replicate each message that is written. If you have a replication factor of 3 then up to 2 servers can fail before you will lose access to your data. We recommend you use a replication factor of 2 or 3 so that you can transparently bounce machines without interrupting data consumption.

The partition count controls how many logs the topic will be sharded into. There are several impacts of the partition count. First each partition must fit entirely on a single server. So if you have 20 partitions the full data set (and read and write load) will be handled by no more than 20 servers (no counting replicas). Finally the partition count impacts the maximum parallelism of your consumers. This is discussed in greater detail in the concepts section.


The configurations added on the command line override the default settings the server has for things like the length of time data should be retained. The complete set of per-topic configurations is documented here.


您需要解锁本帖隐藏内容请: 点击这里

上一条: kafka分布
下一条: kafka修改删除topic

  • 如果你有20个分区的话(读和写的负载),那么处理完整的数据集不超过20个服务器(不计算备份)。这句不是很理解,求大神点拨下

    • 简单一点,一个topic由多个partition组成。比如你的一个topic有20个partition,那么这20个parition最多可以分布在20台机器上。

        bin/kafka-topics.sh --zookeeper zk_host:port/chroot --create --topic my_topic_name
        --partitions 20 --replication-factor 3 --config x=y 最后面的x=y是什么意思,为什么我在自己的kafka上测试,提示我不知道参数“x”