如何为 Kafka 设置 Java 选项? [英] How do I set the Java options for Kafka?

查看:27
本文介绍了如何为 Kafka 设置 Java 选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试验 Kafka,并从主站点上的文档中看到,您可以为 jvm 设置不同的选项,例如堆大小和它使用的垃圾收集器:

I've been experimenting with Kafka and saw from the documentation on the main site that you're able to set different options for the jvm like heap size and the garbage collector that it uses:

http://kafka.apache.org/documentation.html#java

然而,它没有说明如何/在何处设置这些选项.该应用程序带有一个/config 目录,其中包含许多用于配置目的的文件,但没有一个是用于 Java 的.它还带有一个/bin 目录,其中包含一堆 Kafka 脚本,但同样,没有真正说明如何配置 Java.

What it doesn't say, however, is how/where to set these options. The application comes with a /config directory containing a lot of files used for configuration purposes but none that are for Java. It also comes with a /bin directory containing a bunch of scripts for Kafka but again, nothing really indicating how to configure Java.

所以我的问题是,如何配置 Kafka 使用的 Java 选项?是通过文件完成还是有不同的方式?

So my question is, how do I configure the Java options that Kafka uses? Is it done through a file or is there a different way?

推荐答案

极不推荐修改 bin 目录中的脚本.将 Kafka 升级到下一个版本时,提取新的二进制文件将覆盖在脚本中所做的更改.

Modifying a script in the bin directory is highly unrecommended. When upgrading Kafka to the next version, extracting the new binaries would override the changes made in the script.

首选方法应该是在脚本之外设置环境变量KAFKA_HEAP_OPTS.

The preferred way should be to set the environment variable KAFKA_HEAP_OPTS outside the script.

export KAFKA_HEAP_OPTS=-Xmx1G -Xms1G"

如果在通过脚本启动 Kafka 之前设置了 var,它将使用 var 而不是 /bin/kafka-server-start.sh

If the var is set before starting Kafka via the script it will use the var instead of the default values defined in /bin/kafka-server-start.sh

这篇关于如何为 Kafka 设置 Java 选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆