简体   繁体   English

Java中的min.insync.replicas和acks参数在哪里设置?

[英]Where to set parameters min.insync.replicas and acks in Java?

I need to set two parameters min.insync.replicas and acks .我需要设置两个参数min.insync.replicasacks The official documentation says that the parameter min.insync.replicas is the broker's parameter.官方文档说参数min.insync.replicas是broker的参数。 Do I understand correctly that for all topics it should be specified inside the server.properties file?我是否正确理解应该在 server.properties 文件中指定所有主题? And for one - using the command kafka.config.sh.其中之一 - 使用命令 kafka.config.sh。 Acks parameter can only be set when configuring the producer, for example, from the app? Acks参数只能在配置生产者时设置,例如从应用程序? Changes to the file producer.properties won't help?对文件 producer.properties 的更改不会有帮助吗?

Topic-related properties defined in server.properties are effective for all the topics (assuming you don't modify any configuration when creating the topic). server.properties中定义的主题相关属性对所有主题都有效(假设您在创建主题时不修改任何配置)。


Now if for any reason you want to modify one property for a specific topic, you can overwrite the global configuration by providing the new config for that topic.现在,如果出于某种原因您想修改特定主题的一个属性,您可以通过为该主题提供新配置来覆盖全局配置。 For example,例如,

bin/kafka-configs.sh \
    --zookeeper localhost:2181 \
    --alter \
    --entity-type topics \
    --entity-name yourTopicName \
    --add-config min.insync.replicas=2

Alternatively, if you want to create a topic with different configuration to the one defined in server.properties you can use:或者,如果您想创建一个与server.properties中定义的配置不同的主题,您可以使用:

bin/kafka-topics.sh \
    --zookeeper localhost:2181 \
    --create \
    --topic yourTopicName \
    --partitions 1  \
    --replication-factor 3 \
    --config min.insync.replicas=2

Finally, if you want to verify that the configuration is effective, you can simply describe the topic and the added configurations will be shown to the output of ( Configs on the top right corner):最后,如果要验证配置是否有效,可以简单的描述一下主题,添加的配置会显示到(右上角的Configs )的output:

bin/kafka-topics \
    --zookeeper localhost:2181 \
    --describe  \
    --topic yourTopicName

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

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