简体   繁体   English

使用分区在 kafka -.81 中创建/更新主题

[英]creating/updating topic in kafka -.81 with partitions

I would like to create a topic in kafka using version 0.81 and do not have the kafka-topics.sh script at my disposal to do the command line create command.我想使用 0.81 版在 kafka 中创建一个主题,并且我没有 kafka-topics.sh 脚本来执行命令行创建命令。 I need to ensure the topic has multiple partitions in order for multithreaded consumers to consume messages from the topic.我需要确保主题有多个分区,以便多线程消费者使用来自主题的消息。 Each message should only be delivered once and I was told this cannot be done without partitions in a queue even if using the same group ID.每条消息应该只传递一次,我被告知即使使用相同的组 ID,如果队列中没有分区,这也无法完成。

My other question is whether a single consumer run as two separate processes can do the same thing using the same group ID?我的另一个问题是,作为两个独立进程运行的单个使用者是否可以使用相同的组 ID 执行相同的操作? Basically I am currently not reading the messages from the queue fast enough.基本上我目前没有足够快地从队列中读取消息。

Because of the older version I am using I cannot update the topic with partition count as suggested by this command:由于我使用的是旧版本,我无法按照以下命令的建议使用分区计数更新主题:

./bin/kafka-topics.sh --create --zookeeper localhost:2181 --topic 
   my-topic --replication-factor 1 --partitions 2

My other question is whether a single consumer run as two separate processes can do the same thing using the same group ID?我的另一个问题是,作为两个独立进程运行的单个使用者是否可以使用相同的组 ID 执行相同的操作? Basically I am currently not reading the messages from the queue fast enough.基本上我目前没有足够快地从队列中读取消息。

If I understand your question, the answer is YES.如果我理解你的问题,答案是肯定的。 I mean, group.id works in the following way.我的意思是,group.id 的工作方式如下。

  1. If it is the same, it will make, that consumers within group.id will work as with load balancer如果相同,则 group.id 中的消费者将与负载均衡器一样工作
  2. If group.id is different, every group will got own "copy" of the message, so you can perform different operations on the same message content.如果 group.id 不同,每个组都会有自己的消息“副本”,因此您可以对相同的消息内容执行不同的操作。

Because of the older version I am using I cannot update the topic with partition count as suggested by this command由于我使用的是旧版本,我无法按照此命令的建议使用分区计数更新主题

I am pretty confused what are you doing here, but to change parameters of the topic, you shall use "--alter" opion/command and not "--create".我很困惑你在这里做什么,但是要更改主题的参数,你应该使用“--alter”选项/命令而不是“--create”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM