11

When configuring authentication for kafka, the document mentioned that JVM parameters need to be added when starting kafka server. like:

-Djava.security.auth.login.config=/etc/kafka/kafka_server_jaas.conf

Since we are using bin/kafka-server-start.sh to start the server, the document didn't mention where to specify the JVM parameters.

Modifying the kafka-server-start.sh or kafka-server-class.sh is not a good idea, then what will be the right way to add the parameter at the start?

1 Answer 1

23

I'd recommend to use the KAFKA_OPTS environment variable for this.

This environment variable is recognized by Kafka, and defaults to the empty string (= no settings). See the following code snippet from bin/kafka-run-class.sh in the Kafka source code:

# Generic jvm settings you want to add
if [ -z "$KAFKA_OPTS" ]; then
  KAFKA_OPTS=""
fi

So, for example, you can do:

$ export KAFKA_OPTS="-Djava.security.auth.login.config=/etc/kafka/kafka_server_jaas.conf"
$ bin/kafka-server-start.sh

or

$ KAFKA_OPTS="-Djava.security.auth.login.config=/etc/kafka/kafka_server_jaas.conf" bin/kafka-server-start.sh
Sign up to request clarification or add additional context in comments.

2 Comments

How do we handle this for application written in python ? How to pass krb5.conf and jaas.conf properties in such case ?
Please open a separate question for this, as it is off-topic for this one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.