kafka添加和修改topic

原创
半兽人 发表于: 2015-03-10   最后更新时间: 2024-02-19 10:18:54  
{{totalSubscript}} 订阅, 54,943 游览

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.
如果你第一次发布一个不存在的topic时,它会自动创建。你也可以手动创建topic。

Topics are added and modified using the topic tool:
topic的添加和修改使用下面的工具。

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.
副本控制每个消息在服务器中的备份,如果有3个副本,那么最多允许有2个节点宕掉才能不丢数据,集群中推荐设置2或3个副本,才不会中断数据消费。

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.
分区数控制topic将分片成多少log。关于分区数的影响,首先每个分区必须完整的存储在单个的服务器上。因此,如果你有20个分区的话(读和写的负载),那么完整的数据集将不超过20个服务器(不计算备份)。最后,分区数影响消费者的最大并发。这个在概念章节里进行更详细的讨论。

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.
命令行上添加的配置覆盖了服务器的默认设置,服务器有关于时间长度的数据,应该保留。这里记录了每个Topic的完整配置。

更新于 2024-02-19
在线,1小时前登录

不懂咖啡 1年前

你好想提问一下当新的topic被创建的时候,是怎么选择哪些broker作为副本的呢,是随机选择还是根据broker的使用情况?

半兽人 -> 不懂咖啡 1年前

均匀的分布在每个broker上。

River 5年前

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

半兽人 -> River 5年前

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

多想一点 5年前
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”

半兽人 -> 多想一点 5年前

x=y 只是语法说明额。

多想一点 -> 半兽人 5年前

感谢你的回复,为什么我在1.1.1版本的kafka上加上--config x=y,他就不能创建topic啊

查看kafka更多相关的文章或提一个关于kafka的问题,也可以与我们一起分享文章