10

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?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Jakim
  • 1,713
  • 7
  • 20
  • 44

1 Answers1

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
miguno
  • 14,498
  • 3
  • 47
  • 63
  • 1
    How do we handle this for application written in python ? How to pass krb5.conf and jaas.conf properties in such case ? – earl Jan 27 '21 at 17:38
  • 2
    Please open a separate question for this, as it is off-topic for this one. – miguno Jan 28 '21 at 10:04