本文介绍了我在哪里定义topic.metadata.refresh.interval.ms?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对kafka进行一些测试,并希望很快将其放入生产环境中.
我正在使用文件 kafka-console-producer.sh kafka-console-consumer.sh 来测试kafka的功能.

I'm testing kafka a little, and hopefully am going to put it in my production stack soon.
I'm using the files kafka-console-producer.sh and kafka-console-consumer.sh to test kafka's functionality.

我创建了一个具有2个分区的主题,但我发现制作人发送的所有消息都将移至一个分区.

I created a topic with 2 partitions, but I see that all the messages my producer is sending are going to one partition.

我在互联网上进行了搜索,并发现有一个名为 topic.metadata.refresh.interval.ms 的设置,该设置告诉生产者更改当前正在写入的分区,并且默认是10分钟.

I searched this on the internet and read that there is a setting called topic.metadata.refresh.interval.ms that tells the producer to change the partition it's currently writing to, and that the default is 10 min.

我正在尝试更改此设置,但是我不知道在哪里...?

I'm trying to change this setting, but I don't understand where... ?

推荐答案

Kafka属性可以在以下三个文件中找到

Kafka properties can be found in the following three files

server.properties,producer.properties,consumer.properties

server.properties, producer.properties, consumer.properties

这些文件将位于文件夹 kafka-folder/config/ 中.默认情况下,这些文件中将提供某些属性.您可以添加所需的任何属性.属性列表在此链接中给出 https://kafka.apache.org/08/configuration.html .此链接包含服务器,生产者和使用者的所有属性的详细说明.

These files will be available in the folder kafka-folder/config/. By default some properties will be available in those file. You can add what ever the properties you want. The list of properties is given in this link https://kafka.apache.org/08/configuration.html. This link contains detail explanation of all the properties for server, producer and consumer.

由于 topic.metadata.refresh.interval.ms 是生产者配置,因此您需要将此属性添加到 producer.properties 文件

Since topic.metadata.refresh.interval.ms is a producer configuration, you need to add this property in the producer.properties file

请注意,上面的链接是 kafka-0.8版本的属性配置.

Note the above link is the property configurations for the kafka-0.8 version.

这篇关于我在哪里定义topic.metadata.refresh.interval.ms?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 19:54